CoordinatorLayout空留下空间底部 [英] CoordinatorLayout leaves empty bottom space

查看:2041
本文介绍了CoordinatorLayout空留下空间底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发和使用Xamarin Android应用程序。我使用的是与ViewPager TabLayout使标签导航,但我ViewPager,即使有高度=match_parent没有填满整个屏幕。
我相信这是对CoordinatorLayout一些配置错误,但我不能找到一种方法来解决它。

I'm developing and Android App using Xamarin. I'm using the ViewPager with TabLayout to make tab navigation, but my ViewPager, even with height="match_parent" does not fill the whole screen. I believe it's some misconfiguration on CoordinatorLayout, but I can't find a way to fix it.

我的布局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>

这篇关于CoordinatorLayout空留下空间底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆