Overlay image over another android

眉间皱痕 提交于 2019-12-20 14:35:18

问题


I have photo album which shows the image as rounded with white border. Image will be adding dynamically. I tried frame layout but it it not working for me. My try : Adding dynamic image over already existing round shape image..

<FrameLayout
   android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<ImageView 
    android:id="@+id/image"
    android:layout_width="60dip"
    android:layout_height="60dip"
    android:adjustViewBounds="true"
    android:scaleType="centerCrop" />

<ImageView 
    android:id="@+id/imagef"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:background="@drawable/ph_bg" />
</FrameLayout>

Above xml not giving exact result .. any idea ?


回答1:


Use below xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="60dip"
        android:layout_height="60dip"
        android:adjustViewBounds="true"
        android:layout_centerInParent="true"
        android:scaleType="centerCrop" />

    <ImageView
        android:id="@+id/imagef"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:background="@drawable/ph_bg" />

</RelativeLayout>

This will do your task.

Happy coding :)




回答2:


Try setting foreground and background on only one ImageView.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/your_img_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/the_actual_image"
        android:src="@drawable/the_image_overlay" />

</RelativeLayout>


来源:https://stackoverflow.com/questions/16793660/overlay-image-over-another-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!