如何在ListView中使用android:layout_weight [英] How to use android:layout_weight with listview

查看:56
本文介绍了如何在ListView中使用android:layout_weight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想基于android:layout_weight设置UI.我具有以下代码结构

I want to set UI based on android:layout_weight.I have following code structure

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="25"
    android:orientation="horizontal" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="25"
    android:orientation="horizontal" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />
</LinearLayout>

<ListView
    android:id="@+id/relatedContent"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="60dp"
    android:layout_weight="50"
    here=""
    problem=""
    android:cacheColorHint="@android:color/transparent"
    android:divider="@drawable/divider"
    android:listSelector="@drawable/listview_selector_color" >
</ListView>

一切正常,但是当我们设置ListView id时,它将隐藏所有布局.所以任何人都可以帮我解决这个问题.谢谢

Everything work properly but when we set ListView id then it streatch all layout.So please can anyone help me out about this.Thanks

推荐答案

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="25"
    android:orientation="horizontal" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="25"
    android:orientation="horizontal" >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button1" />
</LinearLayout>

<ListView
    android:id="@+id/relatedContent"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_marginBottom="60dp"
    android:layout_weight="50"
    android:cacheColorHint="@android:color/transparent" >
</ListView>

这篇关于如何在ListView中使用android:layout_weight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆