我不知道如何做#3和#1和#2,我尝试了下面的xml,但它不起作用:
<Switch
android:id="@+id/plug_switch"
android:layout_width="120dip"
android:layout_height="10dp"
android:maxHeight="10dp"
android:layout_below="@id/plug_graph_layout"
android:layout_centerHorizontal="true"
android:minWidth="100dp"
android:thumb="@drawable/plugs_button"
android:track="@drawable/btntoggle_selector"
android:textOn=""
android:textOff=""
android:width="120dip" />
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我#1,#2和#3.
谢谢
我的Switch按钮的拇指似乎变得歪斜(开启和关闭状态).在github上也有类似的问题,但那些是人们在API 4.0中使库支持Switch按钮 -
main包含开关按钮,并且有一个拇指和轨道可绘制的应用程序
这就是发生的事情:

这就是它的假设:

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>
Run Code Online (Sandbox Code Playgroud)
switch_thumb_selector.xml
<selector>
<item android:drawable="@drawable/switch_thumb">
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)