我的开关按钮的拇指似乎偏斜(关于&关闭状态)。有在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