简体   繁体   English

ListView的布局问题

[英]Layout problem with ListView

Hi all I'm trying to write a XML code that will allow me to obtain something similar to this: 大家好,我正在尝试编写XML代码,使我可以获得与此类似的东西: 在此处输入图片说明

The relative layout with buttons is a menu with 3 buttons, the problem is that right now the green ListView goes under the buttons (to the bottom of the screen), this is my code: 带按钮的相对布局是一个带有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>

Thanks! 谢谢!

Put everything in the linear layout and set their widths to all be "fill parent." 将所有内容放置在线性布局中,并将其宽度设置为“填充父级”。 Right now you have the linear layout inide the relative layout. 现在,您已经有了线性布局和相对布局。 The liner layout should be set to arrange everything vertically and then place those sub views into the linear layout in the order you want. 衬板布局应设置为垂直排列所有内容,然后将这些子视图以所需顺序放置到线性布局中。

Try adding 尝试添加

android:layout_below="@id/ll"

to your RelativeLayout of buttons 到您的按钮的RelativeLayout

对包含您的ListViewLinearLayout使用android:layout_above="@+id/rel_top"属性

I solved the problem inserting a transparent ImageView under the buttons: 我解决了在按钮下插入透明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>

Thank you guys any way :) 谢谢你们:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM