Bitmap Inside White Circle
I'm trying to fill Bitmap inside white circle, more specifically: I've a Bitmap for example this: And I want this: I've make background gray for understand image. I use this met
Solution 1:
I guess the color you use to paint the oval has ALPHA = 0. Try replacing Color.WHITE with Color(1.0f, 1.0f, 1.0f, 1.0f). Tell me if that solved your problem, and take a look at: What does PorterDuff.Mode mean in android graphics.What does it do?
In this case, for SRC_IN: [Sa * Da, Sc * Da] (Taken from android reference, PorterDuff.Mode)
Solution 2:
Here's an example that uses a shape made in XML.
1) Right-click on your drawable resource folder and create a new Drawable resource file.
2) Paste the following code. This creates a drawable resource which has a pretty similar look to the background that you wanted.
<?xml version="1.0" encoding="utf-8"?><layer-listxmlns:android="http://schemas.android.com/apk/res/android"><item><shapeandroid:shape="rectangle"><sizeandroid:width="50dp"android:height="50dp"/><solidandroid:color="@android:color/darker_gray"/></shape></item><item><shapeandroid:shape="oval"><sizeandroid:width="50dp"android:height="50dp"/><solidandroid:color="@android:color/white"/></shape></item></layer-list>
3) Use the resource in your layout. Substitute my placeholder Android checkbox with your 'tick' resource file.
<RelativeLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/highlight_circle"><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:src="@android:drawable/checkbox_on_background"/></RelativeLayout>
Post a Comment for "Bitmap Inside White Circle"