布局问题:Listview将View推到屏幕之外

发布于 2024-10-02 07:20:41 字数 521 浏览 0 评论 0原文

我有两个文本视图,一个列表视图(顺便说一下,这是一个列表活动)和一个日期选择器。所有内容都应该按此顺序垂直显示。

问题在于 ListView 将日期选择器推到屏幕下方,推到看不见的世界的深处。我希望日期选择器有自己的空间,固定在底部,而列表视图根据需要增长,但仍然允许日期选择器有自己的空间。

+/- 像这样:

~~~~~~~~~~~~~~~ screen top

TextView 1

TextView 2

|

|

|

| ListView [*]

|

|

|

DatePicker (stays here no matter how much List grows or shrinks

~~~~~~~~~~~~~~~ screen bottom

[*] ->这个列表视图会滚动很多,但不会隐藏日期选择器!

我知道要求现成的代码很懒,但是你们能分享一下吗?这让我发疯。我相信我已经尝试了数百万种组合。

非常感谢。这就是完成我的第一个应用程序所需的全部! :-(

I have two textviews, a listview (this is a listactivity, by the way) and a datepicker. All is supposed to be displayed in this order, vertically.

The problem is that the ListView is pushing the datepicker below the screen, to the depths of the unseen world. I want the datepicker to have its own space, fixed at the bottom, while the listview grows as needed, but still allowing datepicker to have its own space.

+/- like this:

~~~~~~~~~~~~~~~ screen top

TextView 1

TextView 2

|

|

|

| ListView [*]

|

|

|

DatePicker (stays here no matter how much List grows or shrinks

~~~~~~~~~~~~~~~ screen bottom

[*] -> This listview will scroll a lot, but won't hide datepicker!

I know it's very lazy to ask for ready code, but could you guys share a light? This is driving me crazy. I've tried millions of combinations I believe.

Thank you a lot. This is all I need to finish my first app! :-(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

む无字情书 2024-10-09 07:20:41

使用 RelativeLayout

<RelativeLayout>
  <!-- other stuff goes here -->
  <DatePicker
    android:id="@+id/some_id"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"/>
  <ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@id/some_id"/>
</RelativeLayout>

顺便说一下,我刚刚给了您基本且重要的部分...您将需要完成代码(例如,您必须为 提供宽度和高度relativeLayout 标签,放置你的 TextViews 等)

Use RelativeLayout:

<RelativeLayout>
  <!-- other stuff goes here -->
  <DatePicker
    android:id="@+id/some_id"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"/>
  <ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@id/some_id"/>
</RelativeLayout>

By the way, I just gave you the basic and important part... you will need to complete the code (for instance, you have to give a width and height to the RelativeLayout tag, put your TextViews, etc.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文