我有我正在處理的這個項目,並且我有一個包含兩個TextView的LinearLayout。我已經使用android:background =「@color/...」設置了LinearLayout的背景顏色,但此適用僅適用於textviews結束的位置。如果它在屏幕中間結束,則顏色停在那裏,其餘的顏色顯示爲白色。 我不明白。我徹底搜索無濟於事。 請大家幫幫我。這是我的佈局文件。如何更改android中包含文本視圖的整個線性佈局的背景顏色
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gold">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gold"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:textSize="20sp" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gold"
android:paddingLeft="15dp"
android:paddingRight="10dp"
android:textSize="15sp" />
</LinearLayout>
問候。
我的線性佈局是根元素,我已經設置了佈局的高度和寬度以匹配父級,但它仍然沒有工作。 –
如果您的LinearLayout用作ListView的單元佈局?如果是這樣,請在Listview中設置背景,而不是單元格本身。 – Francesc
非常感謝。剛剛解決它。 上帝保佑。 –