我有一个drawable shape.xml文件,长这样,没有什么特别的:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp"/>
<solid android:color="?colorPrimary"/>
</shape>
当我在API 21以下运行时,程序会崩溃,因为我认为不能使用"?colorPrimary"。
用户可以选择不同的主题,那么在API 21以下,我可以用什么替代"?colorPrimary"?
如果我这样设置:
<solid android:color="@color/colorPrimary" />
然后我会为所有主题设置相同的颜色,这不是理想的。
在我的styles.xml文件中,用户可以选择10种不同的主题。
我明白我必须将drawable shape.xml移动到drawable-v21文件夹中,但是我应该如何更改上面默认的drawable文件夹中的相同shape.xml以获得相同的功能?