(抱歉我的语言不通,我是法国人)
我需要改变stroke color
形状的。
我有同样的问题描述here https://stackoverflow.com/questions/16775891/how-to-change-solid-color-from-the-code。
当 EditText 不正确时,我需要更改纯色。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp"/>
<stroke android:width="2px" android:color="#CCCCCC"/>
</shape>
答案 :
GradientDrawable myGrad = (GradientDrawable)rectangle.getBackground();
myGrad.setColor(Color.BLACK);
答案的问题是,我不明白长方形物品。
如果我用 EditText 替换它,它将应用于背景,而不是纯色背景。
提前致谢。
编辑:我的错,我想改变Stroke颜色,不纯色。
GradientDrawable myGrad = (GradientDrawable)rectangle.getBackground();
myGrad.setStroke(2, Color.RED);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)