Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 片段布局未覆盖整个屏幕_Android_Google Maps_Android Layout_Android Fragments_Fragment - Fatal编程技术网

Android 片段布局未覆盖整个屏幕

Android 片段布局未覆盖整个屏幕,android,google-maps,android-layout,android-fragments,fragment,Android,Google Maps,Android Layout,Android Fragments,Fragment,我试图在底部导航的一个片段上显示地图 但是,附加的片段并没有覆盖整个屏幕。我尝试将背景色添加到片段中,如下所示: 在尝试将地图添加到片段时,它也不会凸出整个屏幕,而是只显示屏幕的一部分。 下面是我的布局代码: Bottom Navigation.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/a

我试图在底部导航的一个片段上显示地图

但是,附加的片段并没有覆盖整个屏幕。我尝试将背景色添加到片段中,如下所示:

在尝试将地图添加到片段时,它也不会凸出整个屏幕,而是只显示屏幕的一部分。 下面是我的布局代码:

Bottom Navigation.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grey_5">

    <include
        android:id="@+id/search_bar"
        layout="@layout/include_card_view_search_bar" />


        <androidx.core.widget.NestedScrollView
            android:id="@+id/nested_scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none"
            android:scrollingCache="true">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:descendantFocusability="blocksDescendants"
                android:orientation="vertical">

                <View
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_marginBottom="@dimen/spacing_middle" />

                <FrameLayout
                    android:id="@+id/content"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@color/blue_500"/>

            </LinearLayout>

        </androidx.core.widget.NestedScrollView>




    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:background="@color/blue_grey_700"
        app:itemIconTint="@drawable/color_state_white_2"
        app:itemTextColor="@drawable/color_state_white_2"
        app:menu="@menu/menu_bottom_navigation_shifting" />

</RelativeLayout>
该应用程序如下所示:


如果不需要嵌套滚动视图,请尝试使用其他视图组,如LinearLayout或RelativeLayout。问题似乎在于将片段内容包装到NestedScrollView中。

在NestedScrollView中添加android:fillViewport=“true”

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grey_5">

    <include
        android:id="@+id/search_bar"
        layout="@layout/include_card_view_search_bar" />


        <androidx.core.widget.NestedScrollView
            android:id="@+id/nested_scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none"
            android:scrollingCache="true"
            android:fillViewport="true">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:descendantFocusability="blocksDescendants"
                android:orientation="vertical">

                <View
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_marginBottom="@dimen/spacing_middle" />

                <FrameLayout
                    android:id="@+id/content"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@color/blue_500"/>

            </LinearLayout>

        </androidx.core.widget.NestedScrollView>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:background="@color/blue_grey_700"
        app:itemIconTint="@drawable/color_state_white_2"
        app:itemTextColor="@drawable/color_state_white_2"
        app:menu="@menu/menu_bottom_navigation_shifting" />

</RelativeLayout>


您已经在NestedScrollView中获取了FrameLayout(id内容),请尝试从中删除NestedScrollView并将其添加到要用FrameLayout(id内容)替换它的布局中。

我需要嵌套的滚动视图,因为我正在使用OnScrollChangeListener并隐藏工具栏和底部导航barI遇到同样的问题,ScrollView正在包装片段中的内容
android:fillViewport=“true”
做了我需要的,谢谢
 mapFragment = (SupportMapFragment) this.getChildFragmentManager().findFragmentById(R.id.map);
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grey_5">

    <include
        android:id="@+id/search_bar"
        layout="@layout/include_card_view_search_bar" />


        <androidx.core.widget.NestedScrollView
            android:id="@+id/nested_scroll_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none"
            android:scrollingCache="true"
            android:fillViewport="true">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:descendantFocusability="blocksDescendants"
                android:orientation="vertical">

                <View
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_marginBottom="@dimen/spacing_middle" />

                <FrameLayout
                    android:id="@+id/content"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:background="@color/blue_500"/>

            </LinearLayout>

        </androidx.core.widget.NestedScrollView>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:background="@color/blue_grey_700"
        app:itemIconTint="@drawable/color_state_white_2"
        app:itemTextColor="@drawable/color_state_white_2"
        app:menu="@menu/menu_bottom_navigation_shifting" />

</RelativeLayout>