0
我有以下模板更改背景顏色動態和使用邊界
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/borders" >
<RelativeLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="@+id/category_starred_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/rating_not_important"
android:contentDescription="@string/app_name" />
<TextView
android:id="@+id/category_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/category_starred_icon"
android:textIsSelectable="false"
android:textSize="18sp"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:paddingRight="5dp"
android:textColor="@android:color/white"
android:hint="@string/category" />
</RelativeLayout>
</LinearLayout>
我得到一個警告This RelativeLayout layout or its LinearLayout parent is possibly useless; transfer the background attribute to the other view
,我想解決這個問題,但我有後續的問題,我在的LinearLayout邊框就像是一個陰影,但是當我改變背景顏色在我的代碼
mLayout.setBackgroundColor(Color.paseColor(mColorString));
我失去了邊界,我怎麼能解決警告不用其他失去了邊界,主要的問題是背景顏色是動態
你可以刪除線性佈局,只使用相對佈局,並將'android:background =「@ drawable/borders」'設置爲相對佈局 – Raghunandan
是的,但我需要同時顯示'android:background =「@ drawable/borders」 '和backgroundColor設置代碼 – rkmax
我不認爲它可能爲相同的佈局 – Raghunandan