将图片附加到imageview

时间:2014-11-22 18:24:27

标签: android android-layout

将图片附加到imageview

android:src="@drawable/image name" 

2 个答案:

答案 0 :(得分:0)

您可以在ImageView中将fragme drawable用作background,将图像本身用作ImageView的src,就像这样

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/frame"
    android:src="@drawable/image"/>

答案 1 :(得分:0)

ImageView中,您可以将红色圆形图像设置为background,将主图像设置为src,并使用正确的scaleType

或者您的两个ImageView位于FrameLayoutRelativeLayout

但是你需要确保红色边界以外的颜色应该是不透明的并且填充背景颜色。 它就像隐藏了内部图像的额外部分,顶部是图像。

添加了代码:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:id="@+id/imageView_main_image"
        android:background="@drawable/your_main_image_here"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:id="@+id/imageView_background_image"
        android:layout_alignRight="@+id/imageView_main_image"
        android:layout_alignBottom="@+id/imageView_main_image"
        android:layout_alignLeft="@+id/imageView_main_image"
        android:layout_alignTop="@+id/imageView_main_image"
        android:background="@drawable/your_border_image_here"/>

</RelativeLayout>

enter image description here