【问题标题】:ImageView like border for another ImageView AndroidImageView 像另一个 ImageView Android 的边框
【发布时间】:2015-05-19 10:35:25
【问题描述】:

我想在另一个 imageView 中动态插入一个 imageView。 一个 imageView 始终是固定的,我想像使用边框一样使用它。 第二个 imageView 动态插入到另一个内部,CENTER_INSIDE 插入其中。

有可能吗?

【问题讨论】:

标签: java android image xamarin imageview


【解决方案1】:

不要在另一个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"

【讨论】:

  • 如何在边框中插入图像?我需要做一些类似明信片的东西,它的轮廓不仅色彩鲜艳,而且包含文字和图像。
  • 你能在图片中展示你想要做什么的例子吗?
【解决方案2】:

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

Draw 9-patch 工具是一个所见即所得的编辑器,允许您创建位图图像,这些图像会自动调整大小以适应视图内容和屏幕大小。图像的选定部分在图像中绘制的基于水平或垂直的指标进行缩放。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    相关资源
    最近更新 更多