我有一个的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