Android 安卓视图解决方案

Android 安卓视图解决方案,android,android-layout,Android,Android Layout,有人能帮我实现这张图片的观点吗: 紫色和绿色矩形是相对布局中的线性布局。我需要做的是,如果绿色布局可见性设置为去,那么紫色布局将在屏幕底部 有人能帮我做到这一点吗 我没有找到与此问题相关的问题,因为很难对此类问题进行正确的问题查询。您可以使用线性布局,重力作为底部,方向=垂直。现在,当您为下部布局设置visibility=Goe时,上部布局将自动变为底部布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res

有人能帮我实现这张图片的观点吗:

紫色和绿色矩形是相对布局中的线性布局。我需要做的是,如果绿色布局可见性设置为去,那么紫色布局将在屏幕底部

有人能帮我做到这一点吗

我没有找到与此问题相关的问题,因为很难对此类问题进行正确的问题查询。

您可以使用线性布局,重力作为底部,方向=垂直。现在,当您为下部布局设置visibility=Goe时,上部布局将自动变为底部布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/fisrt"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@android:color/holo_green_dark"
        android:orientation="horizontal"></LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@android:color/holo_purple"
        android:orientation="horizontal"></LinearLayout>
</LinearLayout>


</RelativeLayout>

在可见性设置为“消失”后,可以通过编程将其高度设置为0px。如果要将Relativelayout用作最外层,请将我的代码放入Relativelayout中,并将alignParentBottom=true。