2015-05-19 57 views
1

我想要动态插入另一个ImageView的内部的ImageView的。 一个imageView总是固定的,我想使用它像边框。 第二ImageView的是动态的其他和CENTER_INSIDE内部插入到它。ImageView的像边境另一个ImageView的Android的

有可能吗?

+1

你可以在xml中创建,当你吨至使用U可以只设置它的知名度真否则为假 –

+2

有可能与。请检查内容:HTTP://stackoverflow.com/questions/14436641/understanding-androids-layer-list和http://developer.android.com/guide/topics/resources/drawable-resource.html – Karim

回答

2

不要使用ImageView对另一ImageView。在你的情况请按照下列步骤

1 - 创建一个XML文件imageview_border.xml并将其放置在drawable文件夹这样的内容:

<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 - 现在分配android:background="@drawable/imageview_boder"

3-指定图像的ImageView使用android:src属性是这样的:

android:src="@drawable/yourimage" 
+0

我怎样才能插入甚至在边界的图像?我需要做一些明信片,其中的轮廓不仅是丰富多彩的,而且包含文字和图像。 –

+0

你能展示一个你想要在图片中做什么的例子吗? –

+0

http://imageshack.com/a/img673/9862/r7MrsI.png这是示例性图像。 –

1

也许你可以使用9修补图像: http://developer.android.com/tools/help/draw9patch.html

平局9补丁工具是一个所见即所得的编辑器,允许你创建位图图像自动调整大小以适应视图的内容和的大小屏幕。图像的选定部分在图像中绘制水平或垂直基础指标。

相关问题