Color Filters on Custom Shaped ImageViews

140 views Asked by At

I am using the following library to use hexagonal ImageViews in my layout. https://github.com/siyamed/android-shape-imageview. I would like to add a color filter to the custom shaped image views. But I am not able to do so. Any help is appreciated.

Layout 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);

}
0

There are 0 answers