2

私はビューにConstraintLayoutを使用しています。その中にはViewPagerがあり、アダプタに含まれるビューの1つはRecyclerViewです。ContrastLayout内のViewPager内でRecyclerViewを使用する

私はちょうどイメージを置くことを試みるとき、私はもはやスクロールできない高さが欠けている。その高さは私が上に使っているスペース(Toolbar + TabLayout)と同じに見えます。

代わりConstraintLayoutRelativeLayoutを使用している場合、それはこれは私が見たものである

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 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"> 

    <RelativeLayout 
     android:id="@+id/homeToolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@color/toolbarColor"> 

     <android.support.v7.widget.AppCompatImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="8dp" 
      android:padding="7dp" 
      android:src="@drawable/ic_menu" 
      tools:ignore="RtlHardcoded" /> 

     <android.support.v7.widget.AppCompatImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" /> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:gravity="center" 
      android:orientation="horizontal" 
      tools:ignore="RtlHardcoded"> 

      <android.support.v7.widget.AppCompatImageView 
       style="@style/RippleEffect" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginRight="5dp" 
       android:padding="7dp" /> 

      <android.support.v7.widget.AppCompatImageView 
       style="@style/RippleEffect" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginRight="5dp" 
       android:padding="7dp" 
       android:src="@drawable/ic_search" /> 
     </LinearLayout> 
    </RelativeLayout> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/homeTabLayout" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:background="@color/toolbarColor" 
     app:layout_constraintTop_toBottomOf="@+id/homeToolbar" 
     app:tabMode="scrollable" /> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/homeViewPager" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     app:layout_constraintTop_toBottomOf="@+id/homeTabLayout" 

     /> 
</android.support.constraint.ConstraintLayout> 

動作します(最後のダースベイダーを参照)

app:layout_constraintBottom_toBottomOf="parent"を追加することで解決

enter image description here

+0

私は同様のケースがありました。実際にはツールバーのためでした。私はツールバーをスクロール可能にし、それはそのように修正されました。ツールバーをスクロール可能にするか、またはビューページでpaddingBottomを使用することができます – Lukingan

+0

'paddingBottom'を使用することは解決策ではありません。ビューの欠落部分を計算したくないためです。それは迅速な回避策ですが、解決策ではありません。あなたは同意しませんか? –

+0

ちょうど答えを得た@Lukingan。私はちょうど解決策を投稿しました –

答えて

4

ViewPagerに

+1

それはあなたがそれを解決した素晴らしいです。しかし、なぜViewPagerタグの外にTabLayoutを置くのですか? [developer.android.comのリファレンス](https://developer.android.com/reference/android/support/design/widget/TabLayout.html)は、TabLayoutをViewPager内に配置することを明確に説明しています –

+1

「使用している場合このレイアウトは、このレイアウトとともに、setupWithViewPager(ViewPager)を呼び出して2つをリンクすることができます。このレイアウトは、PagerAdapterのページタイトル「then」から自動的に読み込まれます。このビューは、ViewPagerの装飾の一部として使用されることもサポートしています。そのようなレイアウトリソースファイルでViewPagerに直接追加されていれば、どちらの方法でもできるが、これを明確にしていただきありがとうございます。 –

関連する問題