如何在 android 中将 space 放在切换按钮及其文本之间?

How to put space between switch button and its text in android?

我有以下元素:

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

但在设计器上,开关按钮及其文本 "Data about client?" 非常紧密地结合在一起。我试着把 space 放在 ?和“那样 :

android:text="Data about client?    "

但我不是很喜欢这种解决方案

使用标签"android:thumbTextPadding"

我遇到了同样的问题,但对我来说,Sravan Sriram 接受的答案并没有解决问题。

对我有用的是标签

<code>android:switchPadding = "10dp" 

Minimum space between the switch and caption text. docs

好的,请使用这个

android:switchPadding="5dp"

如果您使用 androidx.appcompat.widget.SwitchCompat,则使用 app:switchPadding="8dp"。这对我有用