如何调整框架布局的权重



所以我试图调整框架布局的权重,以便它可以覆盖整个活动页面。发生的事情的结果。

这是我当前活动的xml。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<TextView
android:id="@+id/textView13"
android:layout_width="226dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="68dp"
android:layout_marginTop="26dp"
android:fontFamily="@font/passion_one"
android:gravity="center"
android:text="Kung Fu Tea Order"
android:textColor="#000000"
android:textSize="30sp"
/>
<ListView
android:layout_width="match_parent"
android:layout_height="393dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="90dp" />

<Button
android:id="@+id/addAnotherDrink"
android:layout_width="296dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="100dp"
android:background="@drawable/btn_shape"
android:fontFamily="@font/passion_one"
android:text="ADD ANOTHER DRINK"
android:textColor="#ffffff"
android:textSize="20sp" />
<Button
android:id="@+id/placeOrderBtn"
android:layout_width="296dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="36dp"
android:background="@drawable/btn_shape"
android:fontFamily="@font/passion_one"
android:text="PLACE ORDER"
android:textColor="#ffffff"
android:textSize="20sp" />
<ImageView
android:id="@+id/imageView8"
android:layout_width="83dp"
android:layout_height="71dp"
android:layout_above="@+id/_dynamic"
android:layout_marginBottom="-90dp"
android:layout_toStartOf="@+id/textView13"
app:srcCompat="@drawable/logo"
tools:ignore="UnknownId" />

</RelativeLayout>

在我的java类中,我基本上使用一个按钮,通过使用框架布局作为容器来导航到片段。

真的,有没有办法改变这个框架布局的权重,这样我以前的活动就不会显示了?

您可以将整个活动的基础设置为框架布局。然后,您可以将布局层叠在一起,因此FrameLayoutBase>RelativeLayout from above>FrameLayout您希望覆盖整个屏幕。然后根据需要调整布局的可见性。注:相对布局和叠加FrameLayout都是FrameLayoutBase的独立子项。

最新更新