首页 > 移动平台 > 详细

Android线性布局和常用属性

时间:2021-08-12 12:02:50      阅读:24      评论:0      收藏:0      [点我收藏+]

最常用属性

  1. Android:id

  2. Android:layout_width:宽

  3. Android:layout_height:高

  4. android:background:背景

  5. android:layout_margin:外间距

  6. android:layout_padding:内边距

  7. android:orientation:方向

  8. wrap_content:包含内容,内容有多少,宽度为多少

  9. match_parent:匹配符合点,上一个控件是多少就是多少

  10. android:gravity将里面的控件排列

  11. android:layout_weight:把剩余内容平分

 

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
     tools:context=".MainActivity">
 ?
     <LinearLayout
         android:id="@+id/li_1"
         android:layout_width="200dp"
         android:layout_height="200dp"
         android:orientation="vertical"
         android:background="#000000"
         android:paddingTop="20dp"
         android:paddingBottom="20dp"
         android:paddingLeft="20dp"
         android:paddingRight="20dp"
         android:layout_marginBottom="20dp"
         >
         <View
             android:layout_width="match_parent"
             android:layout_height="200dp"
             android:background="#FF0033"
             />
     </LinearLayout>
     <LinearLayout
         android:id="@+id/li_2"
         android:layout_width="match_parent"
         android:layout_height="200dp"
         android:orientation="horizontal"
         android:background="#0066FF"
         android:layout_marginLeft="20dp"
         android:layout_marginRight="20dp">
 ?
         <View
             android:layout_width="0dp"
             android:layout_height="match_parent"
             android:background="#FFEB3B"
             android:layout_weight="1"
             />
 ?
         <View
             android:layout_width="0dp"
             android:layout_height="match_parent"
             android:background="#2CE033"
             android:layout_weight="1"
             />
 ?
         <View
             android:layout_width="0dp"
             android:layout_height="match_parent"
             android:background="#F44336"
             android:layout_weight="1"
             />
 ?
     </LinearLayout>
 ?
 </LinearLayout>

 

Android线性布局和常用属性

原文:https://www.cnblogs.com/qiezi01/p/15131577.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!