作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个用于标题和图标的顶部栏以及一个搜索栏。当我向上滚动那个隐藏的时候,它就可以了。但是我想在 Activity 首先开始时隐藏搜索栏,并在首先向下滚动时显示。 (像ios whatsapp应用,默认是隐藏的)
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
app:layout_scrollFlags="scroll">
//...
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
//...
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
是否有任何滚动标志。感谢您的帮助。
对不起我糟糕的英语。
最佳答案
将 app:expanded="false"添加到应用栏布局。并且只在其中使用一根钢筋。
<RelativeLayout>
<RelativeLayout
android:layout_height="56dp"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll">
//...
</RelativeLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_height="match_parent"
android:layout_width="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:expanded="false">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
//...
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
关于android - 如何在开始时隐藏搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57162467/
我是一名优秀的程序员,十分优秀!