我在主類中的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'賦予''1''權重,並將高度設置爲'0'。 – PPartisan
用RelativeLayout替換LinearLayout – zombie
我不明白你不想要的內容。 無論如何,組件的高度設置爲match_parent時的行爲是填充父視圖中可用的所有空間。 如果你不想要某些東西被重疊,並且你想要控制每個元素的相對位置,你應該考慮使用RelativeLayout和layout_above以及layout_below,但是再一次,你的問題還不夠清楚,我們不能正確回答它。 – c0rtexx