android - Android CollapsingToolbarLayout 垂直定位子项
问题描述
我正在尝试设置CollapsingToolbarLayout
具有多个视图的视图,但由于CollapsingToolbarLayout
扩展FrameLayout
我无法以正确的顺序放置视图。
这就是我想要实现的目标: 扩展视图:
_____________________________
|Title toolbar x|
|TextView A |
|TextView B |
|TextView C |
|SearchView |
|-----------------------------|
|RecyclerView content |
|... |
|... |
|... |
|... |
|... |
|... |
|_____________________________|
折叠视图:
_____________________________
|Title toolbar x|
|SearchView |
|-----------------------------|
|RecyclerView content |
|... |
|... |
|... |
|... |
|... |
|... |
|... |
|... |
|... |
|_____________________________|
如何CollapsingToolbarLayout
以垂直顺序(TextView A
, TextView B
, TextView C
, SearchView
)将多个视图放置在内部,并仅将 SearchView 设置为固定?
解决方案
如何
CollapsingToolbarLayout
按垂直顺序放置多个视图(TextView
A、TextView
B、TextView
C、SearchView
)
你必须选择你擅长的。
- 使用
LinearLayout
和里面的其他小部件android:orientation="vertical"
。 - 使用
RelativeLayout
和android:layout_below
。 - 使用
ConstraintLayout
和约束,如layout_constraintTop_toBottomOf
.
只设置
SearchView
要固定的?
使用app:layout_collapseMode="pin"
将有助于SearchView
在滚动内容时将其固定在顶部。
PS:您可能必须将其放在CollapsingToolbarLayout
.
推荐阅读
- python - 使用 xpath 提取图像
- python - 将列表值分配给另一个列表
- jms - 连接工厂目标的Weblogic 12C配置
- javascript - 我正在开发一个测验应用程序并尝试用 django 恢复一个问题的不同回答
- python - psycopg2 导入错误 SSL_check_private_key:找不到符号
- javascript - Django:在 AJAX 调用后无法从我的视图中检索变量
- php - paypal 结账 onApprove 功能
- jenkins - 当构建过程需要多个存储库时如何使用 Jenkins 多分支管道
- swift - 基于索引路径的限制行选择
- laravel - Laravel 中的多重身份验证问题