<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#7faacaFF"
android:endColor="#cfe1edFF"
android:gradientRadius="326"
android:type="radial"/>
</shape>
但是在gradientRadius字段中,使用像sp和dip这样的值返回一个错误.
有没有办法为mdpi指定半径和比例,并在其余屏幕密度中自动缩放,还是需要创建多个可绘制的文件?
那么如果你这样做:
RES /抽拉/ foo.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#7faacaFF"
android:endColor="#cfe1edFF"
android:gradientRadius="@dimen/radius"
android:type="radial"/>
</shape>
RES /值-MDPI / dimens.xml
<resources ...> ... <item name="radius" format="float" type="dimen">326</item> .... </resources>
RES /值-HDPI / dimens.xml
<resources ...> ... <item name="radius" format="float" type="dimen">200.34</item> .... </resources>
你怎么看?
http://stackoverflow.com/questions/8501599/radial-gradient-for-different-dpi