【问题标题】:Setting Layout Background Changes Layout Size设置布局背景更改布局大小
【发布时间】:2015-03-27 01:04:59
【问题描述】:

我有这个 XML 代码:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.00"
        android:orientation="horizontal"
        android:weightSum="3.2" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:background="@drawable/addtrials"
            android:orientation="vertical" >

    </LinearLayout>  
            <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:orientation="vertical" >



    </LinearLayout>  
            <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:orientation="vertical" >

    </LinearLayout>  

    </LinearLayout>

不设置背景布局是可以的,但是设置了背景之后,布局高度被拉长了,不知道为什么会这样。

任何帮助将不胜感激

【问题讨论】:

    标签: java android xml layout


    【解决方案1】:

    你有

     android:layout_weight="1" ,
    

    如果图像大小不同,所有布局都会调整为新内容。

    【讨论】:

    • 图像强制布局改变其大小,反之亦然
    猜你喜欢
    • 2013-10-02
    • 1970-01-01
    • 2017-04-03
    • 2015-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多