我有一个EditText
,后台在xml文件中定义:
<EditText
android:id="@+id/myEditText"
style="@style/Theme.x.EditText.ReadOnly"
android:layout_marginRight="5dip"
android:layout_span="7"
android:nextFocusDown="@+id/myEditText2"
android:selectAllOnFocus="true" />
xml文件:my_edit_text.xml
:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@android:color/background_dark" android:endColor="@android:color/background_dark"
android:angle="0"/>
<solid android:color="#FA0000"/>
<stroke android:width="1px" android:color="#5A5D5A"/>
<corners
android:bottomLeftRadius="3dip"
android:topLeftRadius="3dip"
android:bottomRightRadius="3dip"
android:topRightRadius="3dip"
android:color="@color/crAmarelo"/>
<padding
android:left="5dip"
android:right="5dip"/>
</shape>
我需要获得视图的颜色:
EditText et = (EditText) solo.getView(R.id.myEditText);
GradientDrawable gd = (GradientDrawable) et.getBackground();
但我不知道如何从GradientDrawable
获得纯色。