i created custom xml drawable file(image).i used in layout source code:
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#1affffff" /> <stroke android:width="1dp" android:color="#80ffffff" /> <corners android:bottomleftradius="4dip" android:bottomrightradius="4dip" android:topleftradius="4dip" android:toprightradius="4dip" />
want add oval object in center position,but don't know how add in center position. enyone knoes how can add in center position? everyone
create oval drawable
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="@color/mycolor" /> </shape>
option 1
if want add oval @ centre of rectangle, create oval drawable load imageview , position imageview @ centre of imageview rendering rectangle drawable
option 2
first create bitmaps 2 drawables
bitmap rectange = bitmapfactory.decoderesource(getresources(), r.drawable.rectangle); bitmap oval = bitmapfactory.decoderesource(getresources(), r.drawable.oval);
then create canvas , draw bitmaps, play input of drawbitmap
positioning of oval right.
// bitmap bitmap oval in rectange after // finish drawing canvas attached it. bitmap ovalinrectangle = bitmap.createbitmap(rectangle.getwidth, rectangle.getheight, bitmap.config.argb_8888); canvas canvas = new canvas(ovalinrectangle); canvas.drawbitmap(rectangle, 0, 0, null); canvas.drawbitmap(oval, 0,0,null); return ovalinrectangle;
Comments
Post a Comment