zoukankan      html  css  js  c++  java
  • LinearLayout android:layout_weight的理解

    一 不正确的理解

    将各个view(BUTTON等)的android:layout_weight 看作比例关系在父VIEW中显示。

    二 自己的理解

    weight是重要性标识,值越大重要性越强。

    重要性越强,意味着占据父VIEW剩余空间的能力越强。剩余空间可能很大也可能很小,甚至没有。

    三 举例说明证实自己的理解

    <?xml version="1.0" encoding="utf-8"?>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" >

    <Button android:layout_weight="1" android:id="@+id/btn_ok" android:layout_width="wrap_content" android:text="Button1111111111111111111111111111111" android:layout_height="wrap_content"></Button>

    <Button android:layout_weight="2" android:id="@+id/btn_ok2" android:layout_width="wrap_content" android:text="Button2" android:layout_height="wrap_content"></Button>

    <Button android:layout_weight="3" android:id="@+id/btn_ok3" android:layout_width="wrap_content" android:text="Button3" android:layout_height="wrap_content"></Button>

    </LinearLayout>

    btn_ok3重要性最高,所以它占有父view剩余空间能力最强。父view会先紧着btn_ok和btn_ok2显示,这两个view的显示会按其所需要的内容空间进行显示,剩余无论多大的空间都分配给btn_ok3显示。 

       

  • 相关阅读:
    黑产上演《三体》剧情:蠕虫病毒入侵手机群发“钓鱼”短信
    安天AVL联合小米MIUI首擒顽固病毒“不死鸟”
    阿里云存储OSS服务端签名客户端直传
    mariadb 安装配置
    NPOI 打印设置
    windows2008 r2 网络负载均衡搭建
    SqlServer数据库技巧
    达梦数据库备份还原
    ASP.NET CORE Docker发布记录
    DataReader转换
  • 原文地址:https://www.cnblogs.com/maoyu417/p/2110169.html
Copyright © 2011-2022 走看看