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

标签 android android-layout

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

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/

相关文章:

android - 在android中设置剩余进度条颜色

android - 未显示应用程序登录页面 - Android Facebook

Java/Android : I don't understand why this is slower than expected

android - Blackberry - 使用 GPS 和 Google map 估计 Android 应用程序的端口

android - 无法在 ubuntu 13.04 中显示 android 设备

java - EditText 按需小部件

android - 我可以使用 gridview 元素,比如一张图片,然后是字符串,然后是复选框,如何使用?

android - Android中如何在没有绝对布局的情况下将图像相互放置?

java - Httpclient 使用 multipart/form-data 进行 POST

android - 更改 alpha 属性时引发错误