登陆 | 注册 设为首页 | 加入收藏 | 联系我们
太和养老网
热词老年艺术  助老机构  养老系统  

中心区域北京 天津 河北 山西 内蒙古 辽宁 吉林 黑龙江 上海 江苏 浙江 安徽 福建 江西 山东 河南 湖北 湖南 广东 广西 海南 重庆 四川 贵州 云南 西藏 陕西 甘肃 青海 宁夏 新疆 香港 澳门 台湾 全国城市养老院目录 全国县市养老院汇总目录 太和AI作品展 太和养老艺术网AI作品展示

Android布局文件中wrap_content和0dp的区别-飞

 

2023/7/6 17:15:26 ('互联网')

Layout下的布局设置Widget宽高的填充形式:

(1)match_parent:指占满父容器此时要控件的宽或高等于父容器的宽或高。
(2)wrap_content和的用法:指控件的高或宽随内容的长度决定。
(3)设置固定值,可以是30dp,也可以是120dp,想要设置为0dp,必须有weight属性,且值不为0才可以。

不同布局效果(1)第一种情况:
<LinearLayout    android:background="@color/white"    android:layout_width="match_parent"    android:layout_height="100dp"    android:orientation="horizontal">    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"/>    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"/></LinearLayout>
效果图:case1.png(2)第二种情况:
<LinearLayout    android:background="@color/white"    android:layout_width="match_parent"    android:layout_height="100dp"    android:orientation="horizontal">    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"/>    <Button        android:layout_width="match_parent"        android:layout_height="w(spc是什么意思?spc即统计过程控制(Statistical Process Control),是一种借助数理统计方法的过程控制工具。)rap_content"/></LinearLayout>
效果图:case2.png(3)第三种情况:
<LinearLayout   android:background="@color/white"   android:layout_width="match_parent"   android:layout_height="100dp"   android:orientation="horizontal">   <Button       android:layout_width="wrap_content"       android:layout_height="match_parent"/>   <Button       android:layout_width="match_parent"       android:layout_height="wrap_content"/></LinearLayout>
效果图:case3.png(4)第四种情况:
<LinearLayout    android:background="@color/white"    android:layout_width="match_parent"    android:layout_height="100dp"    android:orientation="horizontal">    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"/>    <Button        android:layout_width="match_parent"        android:layout_height="match_parent"/></LinearLayout>
效果图:case4.png(5)第五种情况:
<LinearLayout        android:background="@color/white"        android:layout_width="match_parent"        android:layout_height="100dp"        android:orientation="horizontal">        <Button            android:text="Btn1"            android:layout_width="match_parent"            android:layout_height="wrap_content" />        <Button            android:text="Btn2"            android:layout_width="match_parent"            android:layout_height="wrap_content"/>    </LinearLayout>
效果图:case5.png(6)第六种情况:
<LinearLayout    android:background="@color/white"    android:layout_width="match_parent"    android:layout_height="100dp"    android:orientation="horizontal">    <Button        android:text="Btn1"        android:layout_width="0dp"        android:layout_weight="1"        android:layout_height="wrap_content" />    <Button        android:text="Btn2"        android:layout_width="match_parent"        android:layout_height="wrap_content"/></LinearLayout>
效果图:case6.png设置比重时需要改为0dp的问题

而当我们使用到比重的时候,会在代码中有提示:让我们将layout_width的值设置为0dp


casedemo.png设置之后:
<LinearLayout    android:background="@color/white"    android:layout_width="match_parent"    android:layout_height="100dp"    android:orientation="horizontal">    <Button        android:layout_width="0dp"        android:layout_weight="1"        android:layout_height="wrap_content" />    <Button        android:layout_width="0dp"        android:layout_weight="1"        android:layout_height="wrap_content"/></LinearLayout>
效果图:均分铺满case7.png而如果我们的布局如下:将layout_width的值设置为wrap_content
<LinearLayout    android:background="@color/white"    android:layout_width="match_parent"    android:layout_height="100dp"    android:orientation="horizontal">    <Button        android:layout_width="wrap_content"        android:layout_weight="1"        android:layout_he



扫码加微信详细咨询太和智慧养老产品和平台服务!

 

 





版权声明:

---------------------------------------------------------------


所有信息来源于互联网,本文的版权归原作者所有,不代表本网观点和立场。

本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请发送邮件至 81480447@qq.com 举报,一经查实,本站将立刻删除。



扫码加微信详细咨询太和智慧养老产品和平台服务!

 

养老资讯
助老机构介绍
评论
已有 0 条评论

最新评论

推荐养老院

您希望养老院位于
  • 不限
  • 东城
  • 西城
  • 崇文
  • 宣武
  • 朝阳
  • 丰台
  • 石景山
  • 海淀
  • 门头沟
  • 房山
  • 通州
  • 顺义
  • 昌平
  • 大兴
  • 怀柔
  • 平谷
  • 延庆
  • 密云
您希望的价格范围
  • 不限
  • 500以下
  • 500-1000
  • 1000-2000
  • 2000-3000
  • 3000-5000
  • 5000以上
老人的情况是
  • 不限
  • 自理
  • 半自理
  • 全护理
  • 特护

姓名

年龄

电话

全国城市养老院



关于我们 | 联系方式 | 网站地图 | 友情链接

Copyright 2010-2022 京ICP备18035644号-3 北京太和 版权所有