【问题标题】:Overlay image over another android在另一个机器人上叠加图像
【发布时间】:2013-05-28 13:43:40
【问题描述】:

我有一个相册,它显示图像为圆形,带有白色边框。图像将动态添加。我尝试了框架布局,但它对我不起作用。我的尝试:在已经存在的圆形图像上添加动态图像..

<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>

上面的xml没有给出确切的结果..有什么想法吗?

【问题讨论】:

  • 你能发布应该是什么结果吗?
  • 我希望动态生成的图像作为背景,静态图像作为前景..

标签: android android-layout android-framelayout


【解决方案1】:

在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>

这将完成你的任务。

编码愉快 :)

【讨论】:

    【解决方案2】:

    尝试仅在一个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>
    

    【讨论】:

    • 如何在 ImageView 上设置 Foreground?
    • 使用 android:src... 即前台。
    猜你喜欢
    • 2011-07-05
    • 1970-01-01
    • 1970-01-01
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-16
    • 2021-12-01
    相关资源
    最近更新 更多