zoukankan      html  css  js  c++  java
  • layout_width="0dip"或layout_height="0dip"的情况

    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>

    这几个View宽度的的比例便是1:2:1

  • 相关阅读:
    五大常用算法之四:回溯法
    五大常用算法之三:贪心算法
    五大常用算法之二:动态规划算法
    SSH 只能用于远程 Linux 主机?那说明你见识太小了!
    通过Heketi管理GlusterFS为K8S集群提供持久化存储
    php大文件(视频)分片上传
    php大文件(视频)上传讨论
    php大文件(视频)上传分享
    php大文件(视频)上传问题
    php大文件(视频)上传方法
  • 原文地址:https://www.cnblogs.com/liumin-txgt/p/13070484.html
Copyright © 2011-2022 走看看