我有ListActivity由许多行组成,我试图在行之间自定义分隔符,所以我可以给分隔符:角半径,改变颜色和应用边框等等,
我试图把它称为可绘制的形状布局,但它不起作用,给力关闭。
listactivity代码:
public class Rows extends ListActivity {
String classes[] = { "row1", "row2", "row3", "row4", "row5"};
@Override
protected void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
ListView lv = getListView();
lv.setCacheColorHint(0);
lv.setSelector(android.R.color.transparent);
lv.setDivider(new ColorDrawable(this.getResources().getColor(R.drawable.divider)));
lv.setPadding(20, 0, 20, 0);
lv.setVerticalScrollBarEnabled(false);
lv.setBackgroundResource(R.drawable.list_background);
setListAdapter(new MyArrayAdapter(this, classes)); }
divider.xml代码:
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="5dp" android:height="5dp" android:color="#B22222" />
<solid android:color="#FFFFFF" />
<padding android:left="10dp" android:right="10dp" />
<corners android:radius="10dp" android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>
任何帮助将不胜感激,thabks
答案 0 :(得分:0)
您不应该首先使用ColorDrawable
。如果您的列表参数是非条件的,为什么不直接在XML中设置它:
android:divider="@drawable/divider"