2017-07-10 3 views
0

Hallo, ich bin Mansour aus dem Iran. Ich möchte die App-Leiste beim Scrollen Recyclerview ausblenden. Mein Code funktioniert nicht richtig, sowohl die App-Leiste als auch die Benachrichtigungsleiste werden ausgeblendet. Bitte helfen Sie mir. DankSo blenden Sie die Aktionsleiste beim Scrolling mit Recyclerview

activity_main.xml:

<?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" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="com.sample.recyclerview.MainActivity"> 

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

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

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

<include layout="@layout/content_main" /> 

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

content_main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
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/content_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.sample.recyclerview.MainActivity" 
tools:showIn="@layout/activity_main" 
app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recyclerView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical" /> 

</RelativeLayout> 
+0

Sie Ihre appbar und Statusleiste wollen versteckt sowohl beim Scrollen wenig unklar Frage?. – krishan

Antwort

0

Das Problem ist, dass Sie die layout_behavior haben in der RelativeLayout definiert anstelle des RecyclerView. Dies funktioniert nicht, da RelativeLayout das verschachtelte Scrollen nicht unterstützt.

So bewegen Sie einfach den layout_behavior Element aus der RelativeLayout hinunter zum RecylerView in Ihrem content_main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
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/content_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="com.sample.recyclerview.MainActivity" 
tools:showIn="@layout/activity_main"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recyclerView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

</RelativeLayout> 
+0

Funktioniert nicht richtig !!! Bitte geben Sie mir ein vollständiges Beispiel, wenn es möglich ist. – Mansour

Verwandte Themen