我有以下布局:
<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滤镜正确地将边框涂成橙色? 还有其他选项吗?
MULTIPLY
,边框颜色保持为黑色,填充颜色变为橙色。 - injecteer