【发布时间】:2016-11-16 19:24:49
【问题描述】:
我在主类中的 FragmentLayout 有问题。我有位置应用程序,在我的主要活动中是地图(谷歌 API),我有一个菜单,FragmentLayout(在我的主要活动 XML 中)是 wrap_content(高度),当我点击设置时,显示 FragmentLayout 但它不包括整个屏幕只是一部分,在设置下我看到了地图(不应该在那里)。当我为我的 FragmentLaout 设置 match_parent 时,我在我的主要活动中看不到地图。 这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.globallogic.cityguide.MainActivity"
android:id="@+id/mainLayout"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/navigation_action"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
// THIS IS MY FRAGMENTS:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" //here is this option which cover my whole screen when i put there match_parent
android:id="@+id/main_container"
android:layout_gravity="center"
>
</FrameLayout>
<include layout="@layout/activity_outdoor_map"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/navigation_view"
app:menu="@menu/navigation_menu"
app:headerLayout="@layout/navigation_action"
android:layout_gravity="start"
>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
【问题讨论】:
-
给你的
FrameLayout一个weight的1,并将高度设置为0。 -
将LinearLayout替换为RelativeLayout
-
我不明白你不想要的内容。无论如何,当组件的高度设置为 match_parent 时,组件的行为是填充父视图中的所有可用空间。如果您不希望某些内容重叠并且您想控制每个元素的相对位置,您应该考虑将 RelativeLayout 与 layout_above 和 layout_below 一起使用,但同样,您的问题还不够清楚,我们无法正确回答。
-
我有定位应用程序,在我的主要活动中是地图(谷歌 API),我有一个菜单,FragmentLayout(在我的主要活动 XML 中)是 wrap_content(高度),当我点击设置时, FragmentLayout 显示但它不覆盖整个屏幕只是一部分,在设置下我看到地图(不应该在那里)。当我为我的 FragmentLaout 设置 match_parent 时,我在我的主要活动中看不到地图。以前的答案更改权重和 relativeLayout 不起作用...
标签: android android-layout android-fragments