微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java-将两个图像视图放置在另一个图像视图上

我试图将2 imageView放置在另一个之上.这就是我要完成的.

所以我想要的是,imageView#2将与图片中的imageView#1完全相同.这是我到目前为止尝试过的,但是没有按我想要的那样工作.当我在其他设备中尝试时,图像未保持正确的位置:(

<LinearLayout
android:id="@+id/wrap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tvding"
android:orientation="vertical" >

    <FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

        <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:scaleType="fitCenter"
        android:src="@drawable/base" />

        <ImageView
        android:id="@+id/imageViewCompass"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="25dp"
        android:scaleType="fitCenter"                    
        android:src="@drawable/niddle" />
    </FrameLayout>
</LinearLayout>

提前致谢.

解决方法:

一个选项必须使用FrameLayout

Android Layout Tricks #3: Optimize by merging

或使用RelativeLayout

<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
    <ImageView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image_bottom"/>
    <ImageView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image_top" android:layout_alignParentBottom="true" android:layout_alignParentRight="true"/>
</RelativeLayout>

更新:我发现了这个@ Stackoverflow:
how to place an image over another one on android app?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。