ListView的布局问题

时间:2011-08-19 00:23:54

标签: android xml listview layout

大家好我正在尝试编写一个允许我获得类似内容的XML代码: enter image description here

带按钮的相对布局是一个带有3个按钮的菜单,问题是现在绿色ListView位于按钮下方(到屏幕底部),这是我的代码:

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout
android:id="@+id/widget30"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/backgroundapp">

<ImageView
    android:id="@+id/iv_logo"
    android:src="@drawable/logo_big"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true">
</ImageView>

<LinearLayout
    android:id="@+id/ll"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:layout_below="@+id/iv_logo"
    android:layout_centerHorizontal="true">

    <ListView
        android:id="@+id/lv_events"
        android:textSize="18dp"
        android:cacheColorHint="#00000000"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rel1"
        android:layout_centerHorizontal="true">
    </ListView>
</LinearLayout>

<RelativeLayout
    android:id="@+id/rel_top"
    android:layout_width="fill_parent"
    android:layout_height="55dp"
    android:background="#ff000000"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true">

    <Button
        android:id="@+id/camera"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="CAMERA"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true">
    </Button>
    <Button
        android:id="@+id/bluetooth_connect"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="CONNECT"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true">
    </Button>
    <Button
        android:id="@+id/settings"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="SETTINGS"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true">
    </Button>
</RelativeLayout>
</RelativeLayout>

谢谢!

4 个答案:

答案 0 :(得分:0)

将所有内容放在线性布局中,并将其宽度设置为“fill parent”。现在,您在相对布局中具有线性布局。衬管布局应设置为垂直排列所有内容,然后按照您想要的顺序将这些子视图放入线性布局中。

答案 1 :(得分:0)

尝试添加

android:layout_below="@id/ll"

到您的RelativeLayout按钮

答案 2 :(得分:0)

使用包含android:layout_above="@+id/rel_top"

LinearLayout的{​​{1}}属性

答案 3 :(得分:0)

我解决了在按钮下插入透明ImageView的问题:

<ImageView
    android:id="@+id/place_holder"
    android:src="@drawable/place_holder_transparent_55"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="55dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true">
</ImageView>

谢谢你们任何方式:)