【发布时间】:2014-01-30 10:56:29
【问题描述】:
(对不起我的语言,我是法国人)
我需要更改形状的stroke color。
我有同样的问题描述here。
当 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);
答案中的问题是,我不理解 rectangle 项。 如果我用 EditText 替换它,它将应用于背景,而不是纯色背景。
提前致谢。
编辑:我的错,我想改变 Stroke 颜色,而不是纯色。
【问题讨论】:
-
你的意思是边框不可见??
-
是的,它是可见的,他是黑人。我需要将颜色更改为红色。
-
我认为您将笔画与实体混淆了。试试我的答案,如果你在寻找其他东西,请告诉我。
标签: android android-studio shape