CoordinatorLayout 留下空白底部空间

4
我正在使用Xamarin开发一个Android应用程序。我正在使用ViewPager和TabLayout来进行选项卡导航,但是我的ViewPager,即使设置了height="match_parent",也无法填满整个屏幕。我认为这是在CoordinatorLayout上的一些错误配置,但我找不到解决方法。
我的布局XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="0dp"
    android:background="@android:color/holo_blue_bright">
    <ImageView
        android:background="@drawable/background_aulas"
        android:layout_height="wrap_content"
        android:layout_width="match_parent" />
    <android.support.design.widget.AppBarLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:background="@android:color/transparent"
        android:id="@+id/appbarlayout">
        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />
        <android.support.design.widget.TabLayout
            android:id="@+id/aulas_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="75px"
            local:tabMode="scrollable" />
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.view.ViewPager
        android:id="@+id/aulas_viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        local:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_weight="1"
        android:background="#FF0000"
        android:layout_alignParentBottom="@id/appbarlayout" />
</android.support.design.widget.CoordinatorLayout>

这里是我屏幕的截图:

这是我的屏幕截图:http://imgur.com/nVaHzKK


“蓝色的条形图”是从哪里来的? - curiousMind
在CoordinatorLayout中添加android:fitsSystemWindows= true! - tiny sunlight
为什么你的ViewPager宽度和高度都是match_parent?还有weight属性吗? - CodeAlo
@Coeus 我想让我的ViewPager占据整个CoordinatorLayout的区域,所以我将宽度和高度设置为match_parent。这样做有问题吗?权重属性只是另一种尝试使其发生。 - Eduardo Alberice
@Coeus 收到!我会尝试的! - Eduardo Alberice
显示剩余4条评论
1个回答

0
尝试以下操作。
<?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="0dp"
    android:fitsSystemWindows="true"
    android:background="@android:color/holo_blue_bright">
  <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical">
  <ImageView
      android:layout_height="wrap_content"
      android:layout_width="match_parent" />
  <android.support.design.widget.AppBarLayout
      android:layout_height="wrap_content"
      android:layout_width="match_parent"
      android:background="@android:color/transparent"
      android:id="@+id/appbarlayout">
    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />
    <android.support.design.widget.TabLayout
        android:id="@+id/aulas_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="75px"
        local:tabMode="scrollable" />
  </android.support.design.widget.AppBarLayout>
  <android.support.v4.view.ViewPager
      android:id="@+id/aulas_viewpager"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      local:layout_behavior="@string/appbar_scrolling_view_behavior"
      android:layout_weight="1"
      android:background="#FF0000"
      android:layout_alignParentBottom="@id/appbarlayout" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

非常感谢!将android:fitsSystemWindows="true"添加到CoordinatorLayout中就是答案=D - Eduardo Alberice

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接