2017-05-16 1 views
0

Ich habe ein Problem mit der Symbolleiste, wenn ich nach oben scrolle, die Symbolleiste ausblenden, und wenn ich nach unten scrolle, wird die Symbolleiste sofort angezeigt. Ich möchte Scroll nach oben von RecyclerView, die Symbolleiste zeigt, wie kann ich es tun?Android: Wie Symbolleiste anzeigen, wenn die Liste nach oben gescrollt wird?

Danke !!!!

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
              xmlns:tools="http://schemas.android.com/tools" 
              xmlns:app="http://schemas.android.com/apk/res-auto" 
              android:id="@id/dn_main_container" 
              android:background="@android:color/white" 
              android:layout_width="match_parent" 
              android:layout_height="match_parent" 
              tools:context=".phone.activity.ActivityPerspective"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/listView" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    android:background="@android:color/white" 
    android:layout_marginTop="-56dp" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

<android.support.design.widget.AppBarLayout 
    app:elevation="0dp" 
    android:background="@android:color/transparent" 
    android:fitsSystemWindows="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     app:contentInsetStartWithNavigation="0dp" 
     android:elevation="0dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent"> 
     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize"> 
      <RelativeLayout 
       android:layout_gravity="center_vertical" 
       android:layout_weight="1" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content"> 
       <TextView 
        android:id="@+id/titleView" 
        android:text="Author" 
        android:textSize="9pt" 
        android:textColor="#4D4D4D" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" /> 
      </RelativeLayout> 
      <ImageView 
       android:id="@+id/search" 
       android:src="@drawable/search_dark" 
       android:paddingTop="19dp" 
       android:paddingBottom="19dp" 
       android:layout_marginLeft="6dp" 
       android:layout_width="?attr/actionBarSize" 
       android:layout_height="?attr/actionBarSize" /> 
     </LinearLayout> 
    </android.support.v7.widget.Toolbar> 
</android.support.design.widget.AppBarLayout> 

Antwort

0

Verwendung unter diesem Format-Code wird für Sie arbeiten, was Sie wollen.

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/activity_notice" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
     android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:fitsSystemWindows="true" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 
    <include 
     android:id="@+id/toolbar" 
     layout="@layout/toolbar" /> 
</android.support.design.widget.AppBarLayout> 

<FrameLayout 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycler" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:clipToPadding="false" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
</FrameLayout> 

Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar_help); 
    setSupportActionBar(toolbar); 
0

Sie sollten app:layout_scrollFlags="scroll|enterAlways" in Kind (in Ihrem Fall <android.support.v7.widget.Toolbar>) von <android.support.design.widget.AppBarLayout> add on scroll down verbergen App-Leiste und auf Scroll-Top-Show App-Leiste zu erreichen.

Verwandte Themen