2017-05-16 4 views
0

툴바에 문제가 있습니다. 위로 스크롤하면 툴바가 숨겨지고 아래로 스크롤하면 툴바가 즉시 표시됩니다. RecyclerView의 맨 위로 스크롤하고 싶습니다. 도구 모음이 표시됩니다. 어떻게 할 수 있습니까?Android : 목록을 위로 스크롤 할 때 툴바를 표시하는 방법?

감사합니다 !!!! 형식 코드 아래

<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> 

답변

0

사용이 당신이 원하는 당신을 위해 작동합니다.

<?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

당신은 아래로 스크롤 숨기기 응용 프로그램 막대와 스크롤 톱 쇼 응용 프로그램 표시 줄에 달성하기 위해 <android.support.design.widget.AppBarLayout>의 (귀하의 경우 <android.support.v7.widget.Toolbar>에) 아이 app:layout_scrollFlags="scroll|enterAlways"을 추가해야합니다.

관련 문제