2016-12-08 14 views
0

私はツールバー、EditText Search、ListViewを使用してリストビューをスクロールすると、EditText Searchが非表示になり、スクロールしてEditText Search Show(EditTextのみが表示/非表示、ToolBar )。私は多くの方法を試して検索しましたが、私はこれに対する答えを見つけませんでした。私はToolBarを見つけるだけです。スクロールアップ時にEditText検索を非表示にする方法ListView android

この私のレイアウト:ツールバー内

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.totoroads.android.app.ListViewBottomSheetActivity" 
android:background="@color/backgroundColorGray"> 

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="?attr/colorPrimary" 
    android:minHeight="?attr/actionBarSize" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    app:titleTextColor="@android:color/white" /> 

<LinearLayout 
    android:id="@+id/autoCompleteEditText" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="@color/bg_search_map" 
    android:weightSum="1" 
    android:layout_below="@+id/toolbar"> 

    <AutoCompleteTextView 
     android:id="@+id/autoCompleteTextView" 
     android:layout_width="260dp" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:hint="Enter Place Here" 
     android:backgroundTint="@color/white" 
     android:textColor="@color/white" 
     android:textCursorDrawable="@drawable/color_cursor"/> 

    <Button 
     android:id="@+id/gosearch" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBottom="@+id/autoCompleteTextView" 
     android:layout_toRightOf="@+id/autoCompleteTextView" 
     android:text="TÌM" /> 

    <Button 
     android:id="@+id/filter" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="5dp" 
     android:text="LỌC" /> 

</LinearLayout> 


<ListView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/listView" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" 
    android:divider="@null" 
    android:dividerHeight="0dp" 
    android:layout_above="@+id/footer" 
    android:layout_below="@+id/autoCompleteEditText" /> 

<!-- Bottom Bar No Navigation --> 
<LinearLayout 
    android:id="@+id/footer" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_alignParentBottom="true" 
    android:background="@color/white" 
    style="@android:style/ButtonBar"> 

    <Button 
     android:id="@+id/searchMapButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:background="@color/white" 
     android:text="@string/search_list_map" /> 

    <Button 
     android:id="@+id/otherSearchButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     android:layout_weight="1" 
     android:text="@string/search_nearby" /> 
</LinearLayout> 
<!-- Ending Botton Bar --> 

が上記であるとのEditText検索は、スクロールアップリストビューのEditText検索を非表示にする方法

下回っているのですか?ありがとうございます !

答えて

0

これを試してください。

<?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" 
     android:id="@+id/coordinator" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark"> 

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

      <android.support.design.widget.TabLayout 
       android:id="@+id/tablayout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:tabIndicatorColor="@color/white" 
       app:tabIndicatorHeight="@dimen/profile_tablayout_indicator_height" 
       android:background="?attr/colorPrimary" 
       app:tabGravity="fill"/> 

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

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

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

トライのURL:

https://mzgreen.github.io/2015/06/23/How-to-hideshow-Toolbar-when-list-is-scrolling(part3)/

http://mobikul.com/hideshow-toolbar-scrolling/

+0

ありがとうございますお返事のため、私は、ツールバーのために上下にスクロールまたは使用していない、私はただのEditTextのために、ツールバーを維持したいです検索 –

+0

@ThanhNamPhamこれはあなたに合わせて変更できます。 –

+0

Okey、私は試して戻ってくるだろう:)あなたの考えで –

関連する問題