我的開關按鈕的拇指似乎偏斜(關於&關閉狀態)。有在github上類似的問題,但這些都是爲人民作出的庫,以支持API 4.0〜開關按鈕拇指偏斜?
主開關按鈕包含了開關按鈕,並有一個拇指和跟蹤繪製應用到它
這是發生了什麼事:
這是它如何猜想loook:
switch_track_on.png
main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="112dp"
android:thumb="@drawable/switch_thumb_selector"
android:track="@drawable/switch_track_selector"
android:textOn=""
android:textOff=""/>
</RelativeLayout>
switch_thumb_selector.xml
<selector>
<item android:drawable="@drawable/switch_thumb">
</item>
</selector>
switch_track_selector.xml
<selector>
<item android:drawable="@drawable/switch_track_on" android:state_checked="true"/>
<item android:drawable="@drawable/switch_track_off" android:state_checked="false"/>
</selector>
我解決了它通過設置textColor無論圓的顏色是什麼,並將開關放在一個LinearLayout,請檢查我的答案上面。但是,謝謝:) – Zen
@summers - 如果您將顏色設置爲白色,則它不會是我想要的圓形。它將根據文字長度呈橢圓形。然而,zsolt解決方案是最完美的解決方案。 – Gurpreet