如何在android中的另一个imageview上半重叠imageview [英] how to half overlap imageview on another imageview in android

查看:35
本文介绍了如何在android中的另一个imageview上半重叠imageview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能像这张图片一样将布局 XML 文件中的图片重叠一半.

how can I overlap images half on one another from layout XML file like this image.

推荐答案

只需使用 RealtiveLayout 和负边距

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_landing"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/screen_background">


    <ImageView
        android:background="@color/black"
        android:id="@+id/img_background"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher" />

    <ImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_below="@+id/img_background"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="-40dp"<!-- negative margin to half of height -->
        android:src="@mipmap/ic_launcher" />

</RelativeLayout>

这篇关于如何在android中的另一个imageview上半重叠imageview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆