CoordinatorLayout上的白色非活动底部空间

时间:2017-01-06 11:14:28

标签: 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/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>  

我还有另一个xml文件,我把它放在协调器布局

<?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>

我捕捉到空白空间的错误,它覆盖了我窗口的一部分而不是可点击的。这是在下面的截图: unclickable inactive bottom space 我注意到当我删除app时:layout_behavior =&#34; @ string / appbar_scrolling_view_behavior&#34;从我的ViewPager,这个bug就消失了。但我的标签名称也消失了。我认为它会创建一些不可见的工具栏或类似的东西。

1 个答案:

答案 0 :(得分:2)

由于CoordinatorLayout正在作为子视图的父级,因此要占据全屏,您需要设置高度以匹配父级而不是wrap_content,如下所示:

  

机器人:layout_height =&#34; match_parent&#34;

它会正常工作。

相关问题