在安卓中如何在开关按钮和文本之间添加空格?

33

我有以下元素:

<Switch
    android:text="Data about client?"
    android:id="@+id/connected" />

但在设计界面上,切换按钮和其文本“关于客户的数据?”非常紧密地粘在一起。我尝试在?和“之间放置空格,像这样:

But on designer the switch button and its text "Data about client?" are very glued together. I tried putting space between ? and " like that :

android:text="Data about client?    "

但是我不太喜欢那种解决方案

4个回答

116

我有同样的问题,但是 Sravan Sriram 的被采纳的回答并没有解决我的问题。

What worked for me was the tag

<code>android:switchPadding = "10dp"</code> 

开关和标题文本之间的最小间距。文档


14
app:switchPadding="10dp" 对于SwitchCompat对我有效。 - Hilal

15

好的,请使用这个。

android:switchPadding="5dp"

6
如果您正在使用androidx.appcompat.widget.SwitchCompat,那么请使用app:switchPadding="8dp"。这个对我有用。

2
这同样适用于 com.google.android.material.switchmaterial.SwitchMaterial - Gregory

-8

In This pic

使用标签"android:thumbTextPadding"


20
这不是正确的答案。实际上,这个才是正确的。 - AneesAhmed777

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接