To showing/hiding the password dots in the EditText in android, here’s the easy one-line way. Here’s the dummy layout with an EditText and a CheckBox for toggling the password dots. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="16dp" android:orientation="vertical"> <EditText android:id="@+id/edtPassword" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Enter password" android:inputType="textPassword" /> < android:id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Password" /> </LinearLayout> Now, you can toggle the password on the OnCheckedChangeListener using this snippet. checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean value) { if (value) { // Show Password edtPassword.

Continue reading

In the app, which I am making at my job, I had a situation where I needed a huge number of tabs with the Fragment View Pager. I used a typical TabLayout and ViewPager with a custom FragmentPagerAdapter class as the adapter for ViewPager. This is TabLayout and ViewPager in XML layout. <> <> <> < android:id="@+id/tabs" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" app:tabMode="scrollable"/> </<> < android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </> But, as I run it, this is how it looked like:

Continue reading

Author's picture

Wajahat Karim

Android Developer. Open Source Contributor. Writer. Speaker

Senior Android Developer

Karachi, Pakistan