Android 自定义形状图像视图上的颜色过滤器
我正在使用以下库在布局中使用六边形图像视图。我想在自定义形状的图像视图中添加颜色过滤器。但我不能这样做。感谢您的帮助 布局XML:Android 自定义形状图像视图上的颜色过滤器,android,imageview,background-color,android-custom-view,Android,Imageview,Background Color,Android Custom View,我正在使用以下库在布局中使用六边形图像视图。我想在自定义形状的图像视图中添加颜色过滤器。但我不能这样做。感谢您的帮助 布局XML: 像您所做的那样设置过滤器并没有什么错,但它不适用于指定的六边形图像视图,但适用于其他图像视图。 <com.github.siyamed.shapeimageview.HexagonImageView android:layout_width="100dp" android:layout_height="100dp"
像您所做的那样设置过滤器并没有什么错,但它不适用于指定的六边形图像视图,但适用于其他图像视图。
<com.github.siyamed.shapeimageview.HexagonImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:rotation = "30"
android:src="@drawable/flower"
android:tint="#FF000000"
app:siBorderWidth="3dp"
app:siBorderColor="@color/darkGrey"
android:id="@+id/b_0" />
</LinearLayout>
public class MainActivity extends ActionBarActivity {
private final int random =0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
HexagonImageView b0 = (HexagonImageView) findViewById(R.id.b_0);
HexagonImageView b1 = (HexagonImageView) findViewById(R.id.b_1);
ImageButton i1 = (ImageButton) findViewById(R.id.I_1);
ImageButton i2 = (ImageButton) findViewById(R.id.I_2);
ImageView I2 = (ImageView) findViewById(R.id.b_2);
Drawable d = getResources().getDrawable(R.drawable.flower);
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(cm);
b0.setColorFilter(filter);
}