我想为编辑器制作一个TextView的PaintDrawable背景,以便它可以有圆角的底角。这里是代码:用于TextView的PaintDrawable背景不可见
View head = findViewById(R.id.ibTitle);
PaintDrawable bkgrnd = new PaintDrawable(R.color.Red);
((PaintDrawable) bkgrnd).setCornerRadii(new float [] {0,0, 0,0, 6,6, 6,6});
head.setBackgroundDrawable((PaintDrawable) bkgrnd);
ibTitle是一个TextView。
问题是没有迹象表明其背景,颜色或角落有任何变化。
我必须缺少一些简单的东西。请帮忙。
是的,谢谢。但我想要使用PaintDrawable,我可以重新编程。 – JAW
Lukap,我回来了,并试用了你的方法,并决定这是完成我所需要的最简单的方法。我发现我可以通过head.setBackgroundResource(R.drawable.bkgrnd)设置背景; – JAW
或通过在定义TextView的布局xml中设置android:background =“@ drawable.bkgrnd。对于我使用的bkgrnd.xml: \t < \t \t机器人:bottomRightRadius = “8DP” \t \t机器人:bottomLeftRadius = “8DP” \t \t机器人:topLeftRadius = “0dp” \t \t机器人:topRightRadius = “0dp” \t \t /> –
JAW