Android 无法用线性布局填充空白
我正在使用线性布局设计屏幕。屏幕看起来像: 正如您在上次布局后看到的,出现了一些空白,我无法删除它们 守则:Android 无法用线性布局填充空白,android,Android,我正在使用线性布局设计屏幕。屏幕看起来像: 正如您在上次布局后看到的,出现了一些空白,我无法删除它们 守则: <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<LinearLayout
android:id="@+id/menu_absent_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:padding="8dp"
android:visibility="gone"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/message"
style="@style/BodyStrong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="8dp"
android:textColor="@color/white"
android:text="@string/default_store_message"
/>
<Button
android:id="@+id/navigate_default_menu"
style="@style/BodySmall"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:padding="4dp"
android:text="@string/default_menu"
android:contentDescription="@string/profile_allergies_chart"
android:textColor="@color/white_65_opacity"
android:background="@drawable/fav_box"
tools:ignore="MissingPrefix" />
<Button
android:id="@+id/navigate_location"
style="@style/BodySmall"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:padding="4dp"
android:text="@string/location_search"
android:contentDescription="@string/profile_allergies_chart"
android:textColor="@color/white_65_opacity"
android:background="@drawable/fav_box"
tools:ignore="MissingPrefix" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/sub_menus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:background="@drawable/backgroundwhite"
android:padding="2dp" />
</FrameLayout>
请注意,还有一个“回收者”视图。但它是隐藏的。我不认为这是问题的原因
如何删除空白并进行线性布局以占用剩余空间
编辑:将框架布局宽度更改为“匹配父项”不起作用您的
框架布局
已打开包装内容
试试这个:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll">
将框架布局中的android:layout\u height=“wrap\u content”更改为android:layout\u height=“match\u parent”
以垂直填充所有空间,然后执行任何其他所需更改,使嵌套布局看起来更美观。尝试更改父级框架布局属性
来自
android:layout\u height=“wrap\u content”
至
android:layout\u height=“match\u parent”
您应该将您的FrameLayout
height
属性从wrap\u content
更改为match\u parent
由于wrap_内容
只占用内容所需的空间
而不是整个活动
空间
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
更改:-
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll">
我认为这不是一个完整的布局。如果framenlayout中的
匹配\u parent
不起作用,则在level Upper frame中肯定有什么东西,是什么锁定了它。