0

In the settings page of my app, I am allowing users to turn on or off certain features. I am doing that by using a list view containing a title and switch toggle in each row.

When in list view, Lollipop uses a different switch design, and when you turn it to off mode, the bar is completely invisible, all you see is a circle. Example is here http://postimg.org/image/veos5f3o7/7993cb90/, top switch is On, bottom is off.

I would like to know how I can make the bar visible (e.g. similar to Android OS settings), so you can tell that it is a Switch when in off mode. Thanks

My switch layout declaration is

<Switch
    android:id="@+id/setting_swtich"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true" />
Kent
  • 149
  • 1
  • 4
  • Coloring of the Switch is controlled by your themes - can you include what theming you are using? – ianhanniballake Feb 23 '15 at 22:04
  • And a screenshot? The default background and default switch colors should work fine. – alanv Feb 24 '15 at 01:18
  • @ianhanniballake. I am using Holo.Light, but I just tried a few other Themes and still have a the same problem. – Kent Feb 24 '15 at 02:54
  • 1
    The issue definitely is with the theme you are using as the Switch is present just its of the same color as the background and hence not visible. Please read this http://stackoverflow.com/questions/26714864/how-to-change-the-color-of-a-switchcompat for customising the color. Also just to add try to use SwitchCompat as that will give you the same theme through out all the OS version (pre lollipop as well). – Atul O Holic Feb 24 '15 at 03:08
  • Also, this method might be helpful - public void setTrackDrawable (Drawable track) more details - https://developer.android.com/reference/android/support/v7/widget/SwitchCompat.html#setTrackDrawable%28android.graphics.drawable.Drawable%29 -- Didn't try though. :) – Atul O Holic Feb 24 '15 at 03:18
  • Try this answer, http://stackoverflow.com/questions/27568560/switchcompat-not-showing-thumb-image-on-android-5-0-lollipop-emulator – Lendl Leyba Oct 01 '16 at 04:58

0 Answers0