layout_height="0dip"

来源:互联网 发布:房地产利润率知乎 编辑:程序博客网 时间:2024/05/17 01:43

Layout 中有写法如下:

     layout_height="0dip"  或者 layout_width="0dip"   

     这里的意思是不是用具体的数值来计算高度或者宽度,而是和layout_weight 一起来使用的。经常会有这样的写法: 同一个LinearLayout  (假设是横向的) 中 有几个view ,但是都不指定其具体的宽度,而是使用 layout_weight 参数来指定这几个view所占的比例。每个view所占的宽度的比例是自己的layout_weight 值和总的layout_weight的总和的比值。

例如:

<LinearLayoutandroid:id="@+id/remove_account_area"

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:orientation="horizontal"

       android:background="@android:drawable/bottom_bar">

        <View

           android:layout_width="0dip"

           android:layout_height="match_parent"

           android:layout_weight="1"/>

        <Buttonandroid:id="@+id/remove_account_button"

           android:layout_width="0dip"

           android:layout_height="wrap_content"

            android:layout_weight="2"

           android:layout_marginTop="5dip"

           android:text="@string/remove_account_label" />

        <View

            android:layout_width="0dip"

           android:layout_height="match_parent"

           android:layout_weight="1"/>

   </LinearLayout>

0 0
原创粉丝点击