1

I want to insert dynamically an imageView inside another imageView. One imageView is always fixed and I'd like to use it like border. The second imageView is inserted dynamically inside the other and CENTER_INSIDE into it.

It is possible?

Narendra Singh
  • 4,513
  • 5
  • 30
  • 75
  • 1
    you can just create in xml and when u want to use it u can just set its visibility true else false – Quick learner May 19 '15 at 10:41
  • 2
    it is possible with . Please check this:http://stackoverflow.com/questions/14436641/understanding-androids-layer-list and http://developer.android.com/guide/topics/resources/drawable-resource.html – Karim May 19 '15 at 10:41

2 Answers2

2

Don't use ImageView over another ImageView. In your case follow these steps

1- Create an xml file imageview_border.xml and place it in drawable folder with such contents:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
  <solid android:color="#ffffff" />
  <stroke android:width="1dip" android:color="#dddddd"/>
</shape>

2- Now assign android:background="@drawable/imageview_boder"

3- Assign image to the ImageView using the android:src property like this:

android:src="@drawable/yourimage"
Najeebullah Shah
  • 4,124
  • 3
  • 33
  • 46
1

Maybe you can use 9 patch image: http://developer.android.com/tools/help/draw9patch.html

The Draw 9-patch tool is a WYSIWYG editor that allows you to create bitmap images that automatically resize to accommodate the contents of the view and the size of the screen. Selected parts of the image are scaled horizontally or vertically based indicators drawn within the image.

Field.wei
  • 71
  • 5