首页 > 解决方案 > android:相对布局中两个文本视图之间的间隙

问题描述

Android:我想在两个 textview 之间有 20 dp 的差距,我正在使用相对视图并且已经使用过 textview 2 应该低于 textview 1 ,但我不明白如何在这两个 textview 之间提供更多差距

标签: androidtextview

解决方案


您可以使用填充或边距。我建议保证金。

<TextView 
   android:text="text"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:id="@+id/your_id"
   android:layout_margin="20dp" />

编辑:

感谢@Gabe Sechan 扩大答案。如果您只想要一侧的边距,您可以使用您想要的一侧的特定边距指令。例子:

仅底部边距

<TextView 
  android:text="text"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:id="@+id/your_id"
  android:layout_marginBottom="20dp" />

而另一边

android:layout_marginTop,android:layout_marginLeftandroid:layout_marginRight.


推荐阅读