09.layout_width的使用

把 android:layout_width="0dp", android:layout_weight="1"
横向分三等分

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >
 
    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="Button" />
 
    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="Button" />
 
    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="Button" />
 
</LinearLayout>

android:weight属性使用时基本上是把width或者height设为0dp,这样控件便会按照weight值得比例分配大小,比如将上例子中的第一个button的weight设为2,三个空间宽度比例就成了2:1:1

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • (本文有剧透~) 俗话说得好, 无形装逼,最为致命! 今天为大家介绍的是一部, 主角很帅,主角很屌! 世界上几乎所...
    未来魔书ViiMoo阅读 1,969评论 5 4
  • 夜总是有些晚,路过的雨水有些凋零,就打在路过的车轮上,嘿,只是你的心有些碎了。 不知道南方的雨燕会不会喜欢北国的雪...
    化过的微风阅读 247评论 0 2
  • 今天是端午,在朋友圈看到了浓浓的相聚之情,而我一个人,在学校的宿舍。 作为应届毕业生,在学校却害怕撞见师弟师妹们,...
    小哈喽阅读 336评论 2 1
  • 生我,养我,牵手我的地方 山里山里又山里的地方 曾经魂牵梦绕的故乡 ——罗阳城 就像小孩奋力推开父母 好奇去探索拥...
    不在你以外阅读 558评论 0 3