我有一個包含LinearLayout,它有一個與它相關的樣式,可以給容器20dp的填充。這非常適合99%的內部元素。可能有一個元素我想要在屏幕上延伸(android:layout_width =「match_parent」),並忽略由包含LinearLayout設置的填充。這可能嗎?或者,我是否需要從包含的LinearLayout中移除樣式並將其單獨應用於每個其他元素?Android中的子元素可以忽略其包含的樣式嗎?
(某些屬性排除簡潔)
<LinearLayout
android:padding="20dp">
<TextView
android:id="@+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txtDate"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- Would like this to ignore padding, extend fully. -->
<TextView
android:id="@+id/txtExperienceTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/sub_header_title" />
</LinearLayout>
我不知道的方式做到這一點,無論是。我認爲@Geobits說的是正確的。如果你還沒有在xml中使用該值,那麼我建議創建一個維持特定維度值(類似於Strings.xml)的維度文件。它至少可以讓你遵循一些DRY原則。 – loeschg