如何在Android中以编程方式更改形状的笔触宽度?

如何在Android中以编程方式更改形状的笔触宽度?,第1张

概述这是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 这是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);
总结

以上是内存溢出为你收集整理的如何在Android中以编程方式更改形状的笔触宽度?全部内容,希望文章能够帮你解决如何在Android中以编程方式更改形状的笔触宽度?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1136997.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存