【发布时间】:2017-10-10 15:24:22
【问题描述】:
我创建了一个简单的LinearLayout,其中包含三个相同的元素:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hello"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hello"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hello"/>
</LinearLayout>
现在我要在每对元素之间引入8dp 空格。
以下哪种解决方案被认为更清洁?
或者其他?
【问题讨论】:
-
如何使用视图并将其放在视图之间?
-
@MohammadZarei 你的意思是这里描述的解决方案吗:stackoverflow.com/a/18538656/1494902
-
我建议使用第二个:将来您可能希望在某些自定义类中更改
TextView,并且可以将其嵌入到类中。或者您可能想要为该TextView创建一个style资源并在style中定义边距。
标签: android android-layout android-linearlayout