简体   繁体   中英

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.

截图

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM