我正在使用以下库在我的布局中使用六边形ImageView。 https://github.com/siyamed/android-shape-imageview。我想在自定义形状的图像视图中添加一个滤色器。但我无法这样做。任何帮助表示赞赏。
布局XML:
<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>
MainAcitivity
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);
}