ImageView 像另一个 ImageView 的边框 Android
ImageView like border for another ImageView Android
我想在另一个 imageView 中动态插入一个 imageView。
一个 imageView 总是固定的,我想像使用边框一样使用它。
第二个 imageView 动态插入到另一个图像视图中,并 CENTER_INSIDE 插入其中。
有可能吗?
也许你可以使用 9 补丁图像:
http://developer.android.com/tools/help/draw9patch.html
Draw 9-patch 工具是一种所见即所得的编辑器,可让您创建可自动调整大小以适应视图内容和屏幕大小的位图图像。图像的选定部分根据图像内绘制的指示器水平或垂直缩放。
不要在另一个 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- 使用 android:src
属性 将图像分配给 ImageView
,如下所示:
android:src="@drawable/yourimage"
我想在另一个 imageView 中动态插入一个 imageView。 一个 imageView 总是固定的,我想像使用边框一样使用它。 第二个 imageView 动态插入到另一个图像视图中,并 CENTER_INSIDE 插入其中。
有可能吗?
也许你可以使用 9 补丁图像: http://developer.android.com/tools/help/draw9patch.html
Draw 9-patch 工具是一种所见即所得的编辑器,可让您创建可自动调整大小以适应视图内容和屏幕大小的位图图像。图像的选定部分根据图像内绘制的指示器水平或垂直缩放。
不要在另一个 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- 使用 android:src
属性 将图像分配给 ImageView
,如下所示:
android:src="@drawable/yourimage"