5

私はAppBarLayoutの中にToolbarTabLayoutを持っています。さらに、はCoordinatorLayoutの中にありますが、ViewPagerの外にあります。コーディネーターレイアウトのViewPagerの高さが使用可能以上です

問題は、ViewPager'sの高さが実際に利用可能なものよりも大きいため、私のFragmentからのいくつかのビューがカットされるという問題です。

<?xml version="1.0" encoding="utf-8"?> 
<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="match_parent" 
    android:background="@color/lightGray" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/app_bar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar2" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:popupTheme="@style/AppTheme.PopupOverlay" 
      app:layout_scrollFlags="scroll|enterAlways"/> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabLayout" 
      android:scrollbars="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:fillViewport="false"/> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

</android.support.design.widget.CoordinatorLayout> 

これは私がViewPagerの高さが間違っていると言ったときのことです。
enter image description here

+0

[ViewPager内のフラグメントの一部が画面の下部で切り取られる(Android)](http://stackoverflow.com/questions/34407024/part-of-fragment-inside-viewpager-getting-cut- –

答えて

4

可能ハックは

?のattr/actionBarSizeあるツールバーとして同じ下の余白を追加することができます。他の可能なUIマージンを使って、最高の結果を得ることもできます。

+0

これを行うと、高さの問題が解決されますが、すべてのスクロール効果は削除されます。 また、「スクロール」せずに「enterAlways」を持っている点は何ですか?私は、 "enterAlways | snap | etc"を使うためにスクロールが必須であると思っていました。 –

+1

実際には、layout_scrollFlags属性をすべて削除すると高さの問題が解決します。スクロールは実際にスクロールするために必須です。この解決法は、可能な重複の影響をより受けました。それは同じ設定が他の人にもあまりにも機能しないことが奇妙に感じられるように。あなたがスクロールを維持したい場合は、間違った高さがツールバーの高さにほぼ等しいので、試してみるほんの少しのハックがあります。 **?attr/actionBarSize **の下余白を入れて、スクロールフラグを元のままにしておきます。それで満足のいく結果が得られたら、私はこの答えを更新します。 –

+0

ビューポケットベルに提案されたボトムマージンを試してください。 –

関連する問題