I am developing custom view for android. For that I want give a user ability to select and image using just like when using ImageView
In attr.xml I added bellow code.
<declare-styleable name="DiagonalCut">
<attr name="altitude" format="dimension"/>
<attr name="background_image" format="reference"/>
</declare-styleable>
In custom view I get this value as a Drawable
which was provided in xml as app:background_image="@drawable/image"
TypedArray typedArray = getContext().obtainStyledAttributes(arr, R.styleable.DiagonalCut);
altitude = typedArray.getDimensionPixelSize(R.styleable.DiagonalCut_altitude,10);
sourceImage = typedArray.getDrawable(R.styleable.DiagonalCut_background_image);
I want to create a Bitmap using this sourceImage
which is a Drawable object.
If the way I'm going wrong please provide an alternative.