java - 如何使视图与图片中的视图重叠
问题描述
我有一个如图所示的设计,那么如何在xml中做一个ui如下所示:
我的团队代码 xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/layout1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="top"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@+id/layout1"
android:background="@color/teal_200">
</LinearLayout>
</FrameLayout>
</RelativeLayout>
谁能给我解决方案来设计这件作品。谢谢。
解决方案
这里使用translation
属性是代码
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/layout1"
android:layout_width="200dp"
android:layout_height="100dp"
android:background="@color/purple_700"
android:orientation="horizontal"
android:padding="3dp"<!-- Set the thickness of the border -->
android:translationX="50dp"
android:translationY="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/teal_200"
android:orientation="horizontal"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="100dp"
android:background="@color/purple_700">
</LinearLayout>
</FrameLayout>
推荐阅读
- wordpress - 如何删除 WP 多站点管理员“添加现有用户”部分中的下拉菜单?
- discord.py - discord.py 中随机嵌入消息的显示百分比
- mongodb - MongoDB $text $search 返回确切的短语而不是包含
- html - 带有边框半径和粘性标题的 HTML 表格
- powerbi-desktop - 在 Power BI 中按日期计数(用户的最大日期时间组)
- javascript - 使用 sanityClient 创建后发布文档
- javascript - 烧瓶 javascript 无法打印/记录 jinja2 request.form 变量
- php - 如果类别具有特定的父级,则显示 div
- reactjs - React Formik 没有从 Modal 执行 onSubmit
- regex - 正则表达式:如何查找所有匹配的组(值:特定服务的时间和值)