"@color/rippleEffectColor" Error in Red
App> Res>值> Colors.xml
-我为RippleEffectColor创建了颜色
<resources>
<Color name="rippleEffectColor">#F816A463</Color>
</resources>
App>Res>Drawable
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
**android:color="@color/rippleEffectColor"**
tools:targetApi="lollipop"
>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/btnSignIn"></solid>
<stroke android:color="color/btnSignIn" android:width="2dp"></stroke>
<corners android:radius="2dp"/>
</shape>
</item>
</ripple>
但是我在android:color =“ @ color / rippleEffectColor”上一直出错
最佳答案
您的代码中有两个错字。
我这样运行它,它正在工作:
<resources>
// color has to be lower case
<color name="rippleEffectColor">#F816A463</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="@color/rippleEffectColor"
tools:targetApi="lollipop"
>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/btnSignIn"></solid>
//The @ sign was missing before color
<stroke android:color="@color/btnSignIn" android:width="2dp"></stroke>
<corners android:radius="2dp"/>
</shape>
</item>
</ripple>