Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.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_Coordinator Layout - Fatal编程技术网

Android 坐标布局上的白色非活动底部空间

Android 坐标布局上的白色非活动底部空间,android,coordinator-layout,Android,Coordinator Layout,我有一个带有CoordinatorLayout的xml文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com

我有一个带有CoordinatorLayout的xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:visibility="visible"
    android:gravity="center_horizontal">
            <android.support.design.widget.CoordinatorLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <android.support.design.widget.AppBarLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                    android:layout_marginStart="4dp"
                    android:layout_marginEnd="4dp"
                    android:layout_marginLeft="4dp"
                    android:layout_marginRight="4dp">
                    <android.support.design.widget.TabLayout
                        android:id="@+id/tabLayout"
                        app:tabBackground="@drawable/my_tab_item_bg_selector"
                        app:tabMaxWidth="0dp"
                        app:tabGravity="fill"
                        app:tabMode="fixed"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />
                </android.support.design.widget.AppBarLayout>
                <android.support.v4.view.ViewPager
                    android:id="@+id/viewPager"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
            </android.support.design.widget.CoordinatorLayout>
</LinearLayout>  


我注意到,当我从我的ViewPager中删除app:layout_behavior=“@string/appbar_scrolling_view_behavior”时,错误消失了。但我的标签名称也消失了。我认为它会创建一些不可见的工具栏或类似的东西。

因为CoordinatorLayout是子视图的父视图,所以要占据整个屏幕,您需要设置高度以匹配父视图,而不是像这样包装内容:

android:layout\u height=“match\u parent”


它可以正常工作。

在你的案例中,空白不是“layoutBottom”区域吗?不,我已经更改了代码,删除了不必要的内容,我找到了一些愚蠢的解决方案。我已经从ViewPager和NestedScrollView中删除了app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”,取代了android:layout\u height=“wrap\u content”在AppBarLayout和TableLayout中使用android:layout_height=“45dp”,并将android:layout_marginTop=“45dp”添加到ViewPager中。不是最好的解决方案,但它是有效的。问题确实出在appbar的滚动查看行为上。它增加了空的底部空间。我甚至不在乎为什么。您在ViewPager和NestedScrollView中都添加了appbar_scrolling_view_行为,这导致了问题,它应该只添加到CoordinatorLayout的直接子级中,在您的情况下,这就是ViewPager。NestedScrollView是子布局的一部分。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/nestedScrollData"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <LinearLayout
        android:id="@+id/layoutDataDispatchContacts"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center_horizontal">

        <LinearLayout
            android:id="@+id/layoutFullTableDispatchContacts"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center_horizontal"
            android:background="@drawable/layout_block_background">
            <LinearLayout
                android:id="@+id/tableLinearLayoutDispatchContacts"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:gravity="center_horizontal">
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>