这是circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#00000000"/>
<padding android:left="30dp" android:top="30dp"
android:right="30dp" android:bottom="30dp" />
<stroke android:color="#439CC8" android:width="7dp" />
</shape>
这是我的代码:
textview.setBackgroundResource(R.drawable.circle);
我想在我的java代码中更改笔触粗细.如何以编程方式更改它?
解决方法
您可能需要以编程方式创建它
ShapeDrawable circle = new ShapeDrawable( new ovalShape() );
你需要在此之后设置属性,(填充,颜色等)然后改变它的笔划
circle.getPaint().setstrokeWidth(12);
然后将其设置为视图的背景
textview.setBackgroundDrawable(circle);