Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Draw margin for Image

 
chen young
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks
 
Senthil Ganesan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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
Posts: 154
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic