【问题标题】:How can I move the text in a text view like 10dp to the right?如何将文本视图中的文本(如 10dp)向右移动?
【发布时间】:2017-02-09 00:10:06
【问题描述】:

我想将文本像 10dp 向右移动,而不是 TextView 而是书面文本 + 光标。

我该怎么做?

谢谢。

The "Hallo" is too near the border

【问题讨论】:

    标签: android android-studio textview cursor


    【解决方案1】:

    在您的布局中将 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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

        Padding 属性用于定义任何元素内的对齐偏移量 在android(在您的情况下为TextView),而margin 用于定义围绕(或者您可以在外部调用)元素的偏移量.

        所以你需要

        android:paddingStart="10dp"

        你也可以使用

        android:paddingRight="10dp"

        但这对从右到左对齐的设备有问题。因此,使用 paddingStartpaddingEnd 而不是使用 paddingLeftpaddingRight 是一个好习惯

        您还可以在 android HERE(Click Me) 中找到有关视图属性的所有额外有用的详细信息。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2022-01-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-08-06
          • 2015-10-26
          • 1970-01-01
          • 2016-06-08
          相关资源
          最近更新 更多