android - CoordinatorLayout 留空底部空间

标签 android android-layout xamarin

我正在使用 Xamarin 开发 Android 应用程序。我正在使用带有 TabLayout 的 ViewPager 进行选项卡导航,但我的 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

最佳答案

尝试以下操作。

<?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 - CoordinatorLayout 留空底部空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33940835/

相关文章:

Android,在屏幕底部定位一个元素,固定

java - 以编程方式将文本颜色设置为二次色

c# - Xamarin 表单按钮在 iOS 上带有文本和矢量图像

c# - 如何在 Xamarin 中发送 POST 请求?

android - 如何在 MapView 下方添加 TextView?

android - 膨胀布局和改变 TextView 的值(value)

java - 将范围内的所有质数添加到数组中

android - 更改 CheckedTextView 的 checkMark 或大小

c# - PCL 中的 System.Threading.Timer 等价物

java - Django 更新到 1.6 后,Android http post 请求返回 403