简体   繁体   中英

Android toggle button image looks bad

How can I fix the way my toggle button looks?

On my phone it looks right: http://cs628725.vk.me/v628725086/15a90/XGj_XbSfqdk.jpg But on the other devices it looks like trash: http://cs628725.vk.me/v628725086/15a89/SXXTPMAOk4Q.jpg

<ToggleButton
        android:id="@+id/toggle_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/toggle_selector"
        android:checked="false"
        android:textOff=""
        android:textOn=""
        android:scaleY="0.5"
        android:scaleX="0.5"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

Toggle button selector

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/toggle_on" android:state_checked="true" />
<item android:drawable="@drawable/toggle_off" android:state_checked="false" />

I don't know if this dumb trick works for you, but:

Replace

android:textOff=""
android:textOn=""

with

android:textOff=" "
android:textOn=" "

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