Search code examples
javaandroidandroid-appcompatswitchcompat

Android SwitchCompat thumb not aligned


I'm trying to use SwitchCompat in Android Studio, I put this in build.gradle:

compile 'com.android.support:appcompat-v7:21.+'

but the thumb is not centered with the slider.

Screenshot

and this is my xml:

<android.support.v7.widget.SwitchCompat
    android:id="@+id/allarme"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_gravity="right" />

Can you please help me?


Solution

  • I finally found the problem: there is a bug in appcompat (v21.0.3 at the moment) that afflict hdpi devices. More there: https://code.google.com/p/android/issues/detail?id=78262

    workaround: copy this file in res/drawable-hdpi of your app: https://www.mediafire.com/?6c7537yi73m1e6m