我现在正在这样做
ListView lv = new ListView(this);
ShapeDrawable drawable = new ShapeDrawable();
drawable.getPaint().setColor(Color.BLACK);
drawable.getPaint().setStrokeWidth(5);
lv.setBackground(drawable);
但是没有框架,它用黑色填充整个背景,仅此而已。
请告诉我怎么了?
我现在正在这样做
ListView lv = new ListView(this);
ShapeDrawable drawable = new ShapeDrawable();
drawable.getPaint().setColor(Color.BLACK);
drawable.getPaint().setStrokeWidth(5);
lv.setBackground(drawable);
但是没有框架,它用黑色填充整个背景,仅此而已。
请告诉我怎么了?
选项 1 - 通过 xml 属性:
对于 ListView,我们使用框架制作透明背景 - res/drawable/back.xml:
框架厚度 - 2dp,颜色 - 黑色
将此背景分配给列表:
选项2 - 通过代码相同:
结果:
容器的背景是绿色的。该列表具有带黑色边框的透明背景。