在我的活動中,我有8個LinearLayout。
我想定義一個保證金所有這些(所有的人都會有相同的邊距值)如何在Activity上創建'一般保證金'
是否有可能定義「全球保證金」和每一個存在於我的活動將包含「的LinearLayout」的我在「全球利潤率」中定義的餘量?
(這將節省我的時間來定義餘量爲每個「的LinearLayout」的)
在我的活動中,我有8個LinearLayout。
我想定義一個保證金所有這些(所有的人都會有相同的邊距值)如何在Activity上創建'一般保證金'
是否有可能定義「全球保證金」和每一個存在於我的活動將包含「的LinearLayout」的我在「全球利潤率」中定義的餘量?
(這將節省我的時間來定義餘量爲每個「的LinearLayout」的)
定義維度資源res/values
,例如:
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
然後你就可以在你的佈局XML使用每View
,例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<ListView
android:id="@+id/appsList"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
我建議你閱讀更多關於resources。
我想你可以在所有這8個linearlayout的父佈局上使用填充。 – Shvet