1

この問題を解決するにはかなりの時間がかかりました。私のAppBarLayoutは、私のXMLファイルの1つにRecyclerViewをオーバーラップさせています。私は肯定的な結果なしに意見を並べ替えることを試みました。どんな助けもありがとうございます。ここに私のコードは次のとおりです。ここでAppBarLayoutはRecyclerViewと重複します

<android.support.v4.widget.DrawerLayout 
 
    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:id="@+id/drawer_layout" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:fitsSystemWindows="true" 
 
    tools:openDrawer="start"> 
 

 
    <android.support.design.widget.CoordinatorLayout 
 
     xmlns:android="http://schemas.android.com/apk/res/android" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent" 
 
     android:fitsSystemWindows="true" 
 
     android:background="@color/bg_register"> 
 

 
     <android.support.design.widget.AppBarLayout 
 
      android:layout_width="match_parent" 
 
      android:layout_height="wrap_content"> 
 

 
      <android.support.v7.widget.Toolbar 
 
       android:id="@+id/toolbar" 
 
       android:layout_width="match_parent" 
 
       android:layout_height="?attr/actionBarSize" 
 
       android:background="@color/toolbar"/> 
 

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

 
     <include layout="@layout/content" 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:id="@+id/x"/> 
 
    </android.support.design.widget.CoordinatorLayout> 
 

 
    <android.support.design.widget.NavigationView 
 
     android:id="@+id/nav_view" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="match_parent" 
 
     android:layout_gravity="start" 
 
     app:menu="@menu/activity_main_drawer" 
 
     android:clickable="true"/> 
 
</android.support.v4.widget.DrawerLayout>

は、コンテンツのXMLファイルです:

<RelativeLayout 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" 
 
       xmlns:tools="http://schemas.android.com/tools" 
 
       app:layout_behavior="@string/appbar_scrolling_view_behavior" 
 
       android:orientation="vertical" 
 
       android:background="@color/bg_register" 
 
       android:paddingLeft="10dp" 
 
       android:paddingRight="10dp" 
 
       tools:showIn="@layout/activity"> 
 

 
    <TextView 
 
     android:padding="5dp" 
 
     android:id="@+id/textView" 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:text="@string/list" /> 
 

 
    <android.support.v7.widget.RecyclerView 
 
     android:layout_below="@id/textView" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent" 
 
     android:id="@+id/lv_recycler" 
 
     android:background="@color/white" 
 
     android:scrollbars="vertical" 
 
     android:clickable="true" 
 
     android:fadeScrollbars="true"/> 
 

 
</RelativeLayout>

+0

あなたはスクリーンショットを貼り付けることができますか? – suku

+0

ツールバーを画面から外しているようです。写真を見てください:https://postimg.org/image/80mfleobl/ – BrownT

+0

それは私にはうまく見えます。 recyclerviewが画面の下部に触れていると感じたら、recyclerviewに適切な 'layout_marginBottom'を追加してください。 – suku

答えて

7

は、ツールバーの下に含めるには、この属性を追加します。しかし、それを得るには、ツールバーの下のビューにappbarスクロール・ビューの動作を与える必要があります。これにより、調整されたスクロールが設定されるだけでなく、ツールバーの下に表示されるように下部のビューをレイアウトするようにCoordinatorLayoutに指示します。

調整ツールバーのスクロールを行わない場合は、CoordinatorLayoutを垂直のLinearLayoutに置き換えます。

+0

これはうまくいった。ありがとう! – BrownT

1

それが重なって見えません。その間に空白を入れたい場合は、メインXMLのコンテンツに余白を追加するだけです。また、コンテンツのXMLからルートの相対レイアウトを削除することはできません。あなたはCoordinatorLayoutAppBarLayoutを使用している場合は

app:layout_behavior="@string/appbar_scrolling_view_behavior" 

、あなたはツールバーが最初の道の外に押し出すこと協調スクロールに設定されています

1

私は同じ重複の問題を持っていたが、この理由は、私は私のルートのViewGroupとして

<android.support.constraint.ConstraintLayout 

を持っていたということでした、ではない

<android.support.design.widget.CoordinatorLayout 

ようにもそれをチェック: )

関連する問題