File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes Draw margin for Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Draw margin for Image" Watch "Draw margin for Image" New topic

Draw margin for Image

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197

How can I draw margin for Image by using Rect object (I need also to change the margin color for every image), so in the end I will have a new Image that surrounded by margins.

Senthil Ganesan

Joined: Jul 29, 2010
Posts: 16

try to use a xml file in drawabe folder,with the shape you needed

for eg: in drawabel folder place an border.xml file like below

and in your layout.xml you can set image background has like this

<ImageView android:background="@drawable/border"/>

i hope it may help you little.
zoheb hassan
Ranch Hand

Joined: Apr 01, 2009
Posts: 154

Hi Chen

The Image you are talking about if its taking the entire screen Space then you have to find out the width and height using onSizeChanged() method and retrieve width and height of the screen using getWidth() and getHeight() methods in and use these values in onDraw() method to draw a rectangle.

Hope the solution i mentioned above works
I agree. Here's the link:
subject: Draw margin for Image
It's not a secret anymore!