亚托克斯 2017-05-14 09:23 采纳率: 58.3%
浏览 11236
已采纳

android,怎样让图片浮在布局的最上层,类似css zoom那种

android设计布局遇到一个问题图片说明
想实现image在两个不同背景色的layout的交线位置。
我想的方法是 通过below/above 将image固定在一个Layout下面,然后通过marginTOP=image.heigh/2”。
但结果是layout有一半被压在它没依赖的那个layout下面。
请问这个问题怎么解决

  • 写回答

5条回答 默认 最新

  • 接口的说法 2017-05-15 05:46
    关注

    不知道你的具体的需求情况, 但个人感觉布局合理的话实现不难吧..

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <TextView
                android:id="@+id/t1"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:background="#aaf23000"
                android:layout_weight="1"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:background="#3aa000"
                android:layout_weight="1"/>
        </LinearLayout>
        <ImageView
            android:layout_width="200dp"
            android:background="#ff0"
            android:layout_height="100dp"
            android:layout_centerInParent="true"/>
    </RelativeLayout>![图片说明](https://img-ask.csdn.net/upload/201705/15/1494827065_839148.png)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵