Nei*_*eil 4 android android-layout
为了允许用户提交评论,我有2个视图,垂直堆叠.ListView用于显示输入的注释和LinearLayout页脚,允许用户添加注释(基本上是EditText和按钮).
页脚必须固定在屏幕的底部,ListView必须位于屏幕的上方.它与您在Facebook上为Android添加评论时看到的内容类似.
但是我不希望ListView最初占用整个空间 - 我希望它只占用显示其行所需的空间,但是当用户添加注释时能够扩展到剩余空间 - 同时始终保持在页脚布局上方.
我已尝试过如此建议的LinearLayout Android:如何在底部和listview上面对齐按钮?
但是,这会导致ListView占用页脚上方的所有空间 - 当只有几条注释时 - 所以它主要是空的并且看起来很奇怪.
我已经尝试了一个RelativeLayout父级,其中页脚使用锚定android:layout_alignParentBottom="true".....使用android:layout_above="@id/footerLayout"与上面相同的行为将ListView定位在页脚上方(ListView占用所有剩余空间)...删除它允许ListView'增长但如果它变得太大,它会与页脚重叠.
干杯.
我想这个解决方法会起作用!
<LinearLayout
layout_width="MATCH_PARENT"
layout_height="MATCH_PARENT"
orientation="vertical">
<LinearLayout
layout_width="MATCH_PARENT"
layout_height="0"
android:weight="1"
orientation="vertical">
<YOURLIST
layout_width="MATCH_PARENT"
layout_height="wrap_content"
/>
</LinearLayout>
<YOURVIEW
android:layout_width="MATCH_PARENT"
android:layout_height="WRAP_CONTENT"
android:weight="0"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1332 次 |
| 最近记录: |