Android LinearLayout 绾挎€у竷灞€
16lz
2021-01-23
LinearLayout 绾挎€у竷灞€
LinearLayout 鎸夌収鍨傜洿鎴栬€呮按骞崇殑椤哄簭渚濇鎺掑垪瀛愬厓绱狅紝姣忎竴涓瓙鍏冪礌浣嶄簬鍓嶄竴涓厓绱犱箣鍚庛€?
LinearLayout 涓殑瀛愬厓绱犲睘鎬э細android锛歭ayout_weight鐢熸晥锛屽畠鐢ㄤ簬鎻忚堪璇ュ瓙鍏冪礌鍦ㄥ墿浣欑┖闂翠腑鍗犳湁鐨勫ぇ灏忔瘮渚嬶紝鍔犲叆涓€琛屽彧鏈変竴涓枃鏈锛岄偅涔堝畠鐨勯粯璁ゅ€煎氨鏄?锛屽鏋滀竴琛屼腑鏈変袱涓瓑闀跨殑鏂囨湰妗嗭紝閭d箞浠栦滑鐨刟ndroid:layout_weight鍊煎彲浠ュ悓涓猴細1锛屽鏋滀竴琛屼腑鏈変袱涓笉绛夐暱鐨勬枃鏈锛岄偅涔堜粬浠殑android:layout_weight鍊煎垎鍒负锛?鍜? 锛岄偅涔堢涓€涓枃鏈灏嗗崰鎹墿浣欑┖闂寸殑涓夊垎涔嬩簩锛岀浜屼釜鏂囨湰妗嗗皢鍗犲墿浣欑┖闂寸殑涓夊垎涔嬩竴锛宎ndroid:layout_weight閬靛惊鏁板€艰秺灏忥紝閲嶈搴﹁秺楂樼殑鍘熷垯锛?
鏁堟灉鍥撅細
LinearLayout 鎸夌収鍨傜洿鎴栬€呮按骞崇殑椤哄簭渚濇鎺掑垪瀛愬厓绱狅紝姣忎竴涓瓙鍏冪礌浣嶄簬鍓嶄竴涓厓绱犱箣鍚庛€?
LinearLayout 涓殑瀛愬厓绱犲睘鎬э細android锛歭ayout_weight鐢熸晥锛屽畠鐢ㄤ簬鎻忚堪璇ュ瓙鍏冪礌鍦ㄥ墿浣欑┖闂翠腑鍗犳湁鐨勫ぇ灏忔瘮渚嬶紝鍔犲叆涓€琛屽彧鏈変竴涓枃鏈锛岄偅涔堝畠鐨勯粯璁ゅ€煎氨鏄?锛屽鏋滀竴琛屼腑鏈変袱涓瓑闀跨殑鏂囨湰妗嗭紝閭d箞浠栦滑鐨刟ndroid:layout_weight鍊煎彲浠ュ悓涓猴細1锛屽鏋滀竴琛屼腑鏈変袱涓笉绛夐暱鐨勬枃鏈锛岄偅涔堜粬浠殑android:layout_weight鍊煎垎鍒负锛?鍜? 锛岄偅涔堢涓€涓枃鏈灏嗗崰鎹墿浣欑┖闂寸殑涓夊垎涔嬩簩锛岀浜屼釜鏂囨湰妗嗗皢鍗犲墿浣欑┖闂寸殑涓夊垎涔嬩竴锛宎ndroid:layout_weight閬靛惊鏁板€艰秺灏忥紝閲嶈搴﹁秺楂樼殑鍘熷垯锛?
鏁堟灉鍥撅細
<!-- 甯冨眬涔嬩竴锛氱嚎鎬у竷灞€ LinearLayout 妯悜甯冨眬锛氫竴琛屽鍒? 绾靛悜甯冨眬锛氫竴鍒楀琛? LinearLayout鐨勫睘鎬э細 android:background 璁剧疆鏁翠釜甯冨眬鐢婚潰鐨勮儗鏅? android:orientation="horizontal" 瀛愬厓绱犵殑鎺掑垪闃熷舰锛屾槸妯悜鎺掑垪杩樻槸绾靛悜鎺掑垪 android:gravity="bottom" 瀛愬厓绱犲湪甯冨眬涓殑缂虹渷(榛樿)瀵归綈鏂瑰紡 android:padding 璁剧疆瀛愬厓绱犵殑褰兼杩炴帴锛屼腑闂翠笉鐣欑┖鐧? 瀛愬厓绱犵殑灞炴€э細 android:layout_gravity 璁剧疆鑷韩瀵硅薄鍦ㄧ埗甯冨眬涓殑鐪嬮綈鏂瑰紡锛屽彲浠ユ洿鏂扮埗甯冨眬瀵硅薄缁欏畾鐨勭己鐪佺殑鍊? android:layout_weight 灏嗙埗甯冨眬涓墿浣欑殑灏哄鎸夊悇鍏勫紵鍏冪礌鐨剋eight鍊兼瘮渚嬭繘琛屽~鍏咃紱 --> <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <TextView android:text="red" android:gravity="center_horizontal" android:background="#aa0000" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="green" android:gravity="center_horizontal" android:background="#00aa00" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="blue" android:gravity="center_horizontal" android:background="#0000aa" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="yellow" android:gravity="center_horizontal" android:background="#aaaa00" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <TextView android:text="row one" android:textSize="15pt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="row two" android:textSize="15pt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="row three" android:textSize="15pt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:text="row four" android:textSize="15pt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"/> </LinearLayout></LinearLayout>
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer