我有一個的LinearLayout背景,以創建一個圓角的外觀如此設置爲繪製文件:試圖setBackgroundColor在適配器,可繪製工作不正常
<LinearLayout
android:id="@+id/layout_top"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/rectangle_topcorner">
<TextView android:layout_width="fill_parent"
android:id="@+id/textView1"
android:layout_height="wrap_content"
android:text="Impact"
android:layout_gravity="center"
android:textColor="@android:color/white"
android:layout_marginLeft="10dip" />
</LinearLayout>
在我的適配器,我膨脹後佈局的項目,我想給的backgroundColor更改爲「不同」繪製,以改變背景色:
LinearLayout top = (LinearLayout) view.findViewById(R.id.layout_top);
top.setBackgroundColor(R.drawable.rectangle_topcorner_high);
的問題是,這樣做後,矩形失去了圓角的外觀和它只是一個普通的老廣場。
的2繪項目: rectangle_topcorner
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:id="@+id/background_shape" >
<corners android:topLeftRadius="30dp"
android:topRightRadius="30dp" />
<solid android:color="#005577"/>
</shape>
rectangle_topcorner_high
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:id="@+id/background_shape" >
<corners android:topLeftRadius="30dp"
android:topRightRadius="30dp" />
<solid android:color="#83162D"/>
</shape>
我失去了一些東西保存圓角?
它是在listview項目中嗎?然後嘗試調用'invalidate' – 2014-12-05 08:42:44
可以請你張貼適配器完整的代碼? – 2014-12-05 08:58:47