java - 如何在布局中包含 listView 以及布局中的其他视图
问题描述
我有一个ImageView
顶部和TextView
底部的活动。我想ListView
在两者之间添加一个,我该怎么做?
解决方案
将线性布局作为父布局并使其方向垂直。依次添加imageview、listview、textview。现在为 listview 提供权重为 1,其高度为 0dp。为 listview 提供权重 1 将允许它在布局的整个空白空间中传播。希望这可以帮助
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp" />
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
推荐阅读
- ruby-on-rails - SimpleForm: has_many/belongs_to with
- ios - UIBezierPath 未正确呈现
- python - 如何正确地将 HyperlinkedRelatedField 字段添加到序列化程序?
- php - Google recaptcha 不在服务器上工作,但在 localhost 上工作
- html - 浮动 div 给出不同高度的列
- angular - 如何配置 WebStorm 以停止导入完整的 Typescript 路径?
- docker - 我无法在多个节点中部署容器
- php - 如何查询 Laravel Eloquent
- python - Python 通过函数装饰器转换 ast
- autocad - Autolisp 例程有时只有效