为了让用户提交评论,我有两个视图,垂直堆叠。一个用于显示输入的注释的ListView和一个LinearLayout页脚,用于允许用户添加注释(基本上是一个EditText和一个按钮)。
页脚必须锚定在屏幕的脚上,ListView必须位于屏幕的上方。这与你在facebook上为Android添加评论时看到的相似。
不过,我不希望ListView最初占用整个空间--我希望它只占用显示其行所需的空间,但在用户添加注释时能够扩展到剩余的空间--同时始终保持在页脚布局之上。
我试过像这里建议的那样使用LinearLayout,Android: How can you align a button at the bottom and listview above?
然而,这导致ListView占用了页脚上方的所有空间--当只有几个注释时--所以它主要是空的,看起来很奇怪。
我尝试过一个RelativeLayout父母,其中页脚是使用android:layout_alignParentBottom="true"锚定的…使用ListView定位页脚上方的android:layout_above="@id/footerLayout"强制执行与上面相同的行为(ListView占用了所有剩余的空间)。删除这允许ListView‘增长’,但它重叠的页脚,如果它增长太大。
干杯。
发布于 2012-10-13 14:47:41
我想这个解决办法会奏效的!
<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>发布于 2012-10-13 14:12:20
我想其中一种方法是在XML中使用android:fillViewport属性。看这篇由Romain:http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/撰写的博文
https://stackoverflow.com/questions/12873880
复制相似问题