我试图模仿 HTC SMS 应用程序(传统视图)的行为,其中显示所有消息,并在下面显示 EditText。正如您在屏幕截图中看到的,向上滚动时,EditText 从底部滚动。
即使阅读了多篇文章(例如带有 ListView 和按钮的 Android 布局 https://stackoverflow.com/questions/2383847/android-layout-with-listview-and-buttons和这个网站:http://www.finalconcept.com.au/article/view/android-keeping-buttons-visible http://www.finalconcept.com.au/article/view/android-keeping-buttons-visible),它没有按预期工作。
感谢评论和EditText 现在显示在 ListView 下 https://stackoverflow.com/questions/5319965/edittext-now-showing-under-listview,我设法让我的 ListView 占据所有可用空间并在完成后开始滚动。 EditText 现在始终显示在屏幕底部。我希望当我向上滚动时它消失在底部 - 现在它仍然在底部
当前代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/android:list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<TableLayout
android:layout_weight="0"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<EditText android:id="@+id/newmessagecontent"
android:layout_height="150dp"
android:singleLine="false"
android:gravity="top"
android:layout_width="250dp"
android:layout_alignParentTop="true"
/>
<Button android:layout_height="wrap_content"
android:id="@+id/sendmessage"
android:text="Send"
android:layout_width="wrap_content"
/>
</TableRow>
</TableLayout>
</LinearLayout>
我认为你需要在这里实施的是对SeparatedListAdapter
来自杰夫·夏基从这里Article http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/。在这篇文章中,他不仅添加了两个Adapters
to a ListView
还解释了如何使用标头将它们分开(如果您愿意)(您可以删除这部分代码)。
所以我的意思是,这是你的第一次Adapter
将是其行的数据,第二个Adapter
将是一个没有数据的虚拟数据,仅指向View
用你的控制或其他什么。
这样ListView
你想在底部添加的内容都是可滚动的。
希望这可以帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)