スクロール・レベルに関係なく、スワイプ・ダウン時に表示され、スワイプ・アップ時にコラプスする検索ツールバーを作成したい。このツールバーの高さを検索エリアとして正確に設定したいときに問題が発生しました。下にスワイプしても問題ありません。スワイプの検索アイコンは引き続き表示されます。 たとえば、AppBarLayout android:layout_height = "wrap_content"を100dpに変更すると、ツールバーを非表示にすることが可能になりますが、表示が悪く異なる解像度で問題が発生する可能性があります。私が達成したいのは、Play Marketアプリでの検索です。そこではどのように行われていますか?"wrap_content"の高さでCollapsingToolbarを作成するには?
<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="test.proekt101_test.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways|snap"
>
<SearchView
android:id="@+id/searchView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
>
</SearchView>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
私は 'SearchView'に 'android:fitsSystemWindows =" true "'を追加して 'AppBarLayout'から削除しました。 –