如何在Android中更改Switch的高度和宽度 [英] How to change height and width of Switch in Android
本文介绍了如何在Android中更改Switch的高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 我想将开关的宽度设置为120dp,高度为30dp.
- 我也不想在拇指上留下任何文字,但希望拇指盖覆盖总宽度的一半,所以我希望它为60dp.
- 此外,我希望拇指的高度小于从3个侧面可以看到的背景开关的高度.
我不知道如何执行#3,对于#1和#2,我尝试了以下xml,但是它不起作用:
I have no idea how to do #3 and for #1 and #2, I tried the following xml, but it is not working:
<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" />
有人可以在#1,#2和#3方面帮助我吗?
could someone please help me with #1, #2 and #3.
谢谢
推荐答案
添加此 android:switchMinWidth ="56dp"
并尝试
<Switch
android:id="@+id/plug_switch"
android:layout_width="120dip"
android:layout_height="10dp"
android:maxHeight="10dp"
android:thumbTextPadding="25dp"
android:switchMinWidth="56dp"
android:layout_below="@id/plug_graph_layout"
android:layout_centerHorizontal="true"
android:minWidth="100dp"
这篇关于如何在Android中更改Switch的高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文