如何将文本视图中的文本向右移动 10dp?

How can I move the text in a text view like 10dp to the right?

我想将文本向右移动 10dp,不是 TextView,而是写入的文本 + 光标。

我该怎么做?

谢谢。

The "Hallo" is too near the border

在您的布局中将 android:paddingStart =10dpandroid:paddingLeft =10dp 提供给此 Textview

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingStart="10dp"
    android:text="Hello!"/>

有关差异的详细说明,请参阅 this link

在 TextView 的开头添加一些填充!

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingStart="8dp"
    android:text="done!"/>

Padding 属性用于定义 android 中任何元素内的对齐偏移量(在您的情况下为 TextView),而边距用于定义周围的偏移量(或者你可以在外面调用)元素。

所以在你的情况下你需要

android:paddingStart="10dp"

你也可以使用

android:paddingRight="10dp"

但这对 right-to-left 对齐的设备有问题。因此,使用 paddingStartpaddingEnd 而不是使用 paddingLeftpaddingRight.

您还可以在 android HERE(Click Me).

中找到有关视图属性的所有额外有用的详细信息