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?
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?
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"
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.