Android RelativeLayout:当两个视图都不是';t在同一容器中
我在LinearLayout中有一个标题栏(#lotoptitleBar),LinearLayout将是屏幕的全尺寸,现在,我想显示一个视图(#lotFloatView)引用下面的标题栏,但两个视图不在同一个容器级别,因此下面的布局不起作用,如果有人知道的话,请帮我换一下Android RelativeLayout:当两个视图都不是';t在同一容器中,android,android-relativelayout,Android,Android Relativelayout,我在LinearLayout中有一个标题栏(#lotoptitleBar),LinearLayout将是屏幕的全尺寸,现在,我想显示一个视图(#lotFloatView)引用下面的标题栏,但两个视图不在同一个容器级别,因此下面的布局不起作用,如果有人知道的话,请帮我换一下 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:orientation="vertical">
<LinearLayout android:id="@+id/lotTopTitleBar"
android:layout_width="match_parent"
android:layout_height="50dp">
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="50dp">
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/lotFloatView"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_below="@id/lotTopTitleBar">
<Button android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@null" />
<Button android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@null" />
</LinearLayout>
</RelativeLayout>
我认为可以通过使用相对布局而不是线性布局来实现这一点。我还没有测试过它,但它应该可以工作
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout android:id="@+id/lotTopTitleBar"
android:layout_width="match_parent"
android:layout_height="50dp">
</LinearLayout>
<LinearLayout android:id="@+id/lotFloatView"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_below="@id/lotTopTitleBar">
<Button android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@null" />
<Button android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@null" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/lotTopTitleBar"
android:id="@+id/lotLL"
android:layout_weight="1">
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_below="@id/lotLL"
android:layout_height="50dp">
</LinearLayout>
</RelativeLayout >
编辑
<LinearLayout android:layout_width="match_parent"
android:layout_below="@id/lotLL"
android:layout_alignParentBottom="true"
android:id="@+id/lotLastLL"
android:layout_height="50dp">
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/lotTopTitleBar"
android:layout_above="@id/lotLastLL"
android:id="@+id/lotLL"
>
</LinearLayout>
我不认为我可以在RelativeLayout中使用“layout\u weight”,正如您所写的那样,“lotLL”没有任何尺寸。正确。。我没看那个。。我想展示的是如何将LL更改为RLLinearLayout#lotLastLL不能声明“layout_below=@id/lotLL”如果id=lotLL没有定义,Intellij IDEA会有这样一个错误报告“android apt编译器错误:找不到与给定名称匹配的资源(在'layout_below'处,值为'@id/lotLL')。”@TarunI use POPPUPWINDOW解决了这个问题,我想我应该让你知道我是通过use POPPUPWINDOW解决的,详情请查看