我想爲編輯器製作一個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