我有以下布局:
<LinearLayout
android:id="@+id/myButton"
android:layout_width="@dimen/logo_radius"
android:layout_height="match_parent"
android:background="@drawable/myShape">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/driver_half"/>
</LinearLayout>
以及以下myShape
可绘制对象:
<selector>
<item><shape android:shape="oval">
<stroke android:color="@android:color/black" android:width="4dp"/>
<solid android:color="@android:color/white" />
</shape></item>
</selector>
我应用了以下过滤器:
myButton.getBackground().setColorFilter( orange, PorterDuff.Mode.ADD );
结果看起来是这样的:
然后我将 myShape 更改为带圆角的矩形:
<selector>
<item>
<shape
android:shape="rectangle">
<corners android:bottomLeftRadius="@dimen/logo_radius" android:bottomRightRadius="2dp" android:topLeftRadius="@dimen/logo_radius" android:topRightRadius="2dp"/>
<stroke
android:width="4dp"
android:color="@android:color/black"/>
<solid android:color="@android:color/white"/>
</shape>
</item>
</selector>
结果看起来像:
左边部分没有应用过滤器,右边部分有过滤器。
我想得到什么:
我应该怎么做才能使用 Porter-Duff 过滤器正确地将边框涂成橙色?还有其他选择吗?