gpt4 book ai didi

android - 一种布局覆盖另一种布局

转载 作者:行者123 更新时间:2023-11-29 02:33:46 24 4
gpt4 key购买 nike

我需要一个布局覆盖另一个布局(它们可以有任何高度),像这样:

enter image description here

当屏幕变小时,我需要棕色布局变低,像这样:

enter image description here

我有这段代码可以做到这一点:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

<FrameLayout
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:background="#dd6600">

<TextView
android:layout_width="wrap_content"
android:layout_height="100dp"
android:text="One"/>
</FrameLayout>

<FrameLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:background="#bbbbbb">

<TextView
android:layout_width="wrap_content"
android:layout_height="150dp"
android:text="Another"/>
</FrameLayout>

</FrameLayout>

在小高度上它工作正常,但在大屏幕上我有这个:

enter image description here

你能帮我解决这个问题吗?

最佳答案

您可以从 CoordinatorLayout 中受益 here做这样的效果

关于android - 一种布局覆盖另一种布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48173237/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com