开发者

Layout problem: Listview pushes View outside screen

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 pu开发者_StackOverflow社区shing 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! :-(


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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜