ZhipSoft.com
              冬去春來
                  鄭重聲明:本Blog純屬個人學習、工作需要,記錄相關資料。請不要發表任何有人身攻擊的言論,謝謝!!www.ZhipSoft.com
          posts - 94,comments - 149,trackbacks - 0

          LinearLayout和RelativeLayout

          共有屬性:
          java代碼中通過btn1關聯次控件
          android:id="@+id/btn1"

          控件寬度
          android:layout_width="80px"    //"80dip"或"80dp"
          android:layout_width =“wrap_content”
          android:layout_width =“match_parent” 

          控件高度
          android:layout_height="80px"    //"80dip"或"80dp"
          android:layout_height =“wrap_content”
          android:layout_height =“match_parent”

          控件排布
          android:orientation="horizontal”
          android:orientation="vertical“

          控件間距
          android:layout_marginLeft="5dip"      //距離左邊
          android:layout_marginRight="5dip"      //距離右邊
          android:layout_marginTop="5dip"      //距離上面
          android:layout_marginRight="5dip"      //距離下面

          控件顯示位置
          android:gravity="center"    //left,right, top, bottom
          android:gravity="center_horizontal"

          android:layout_gravity是本元素對父元素的重力方向。
          android:layout_gravity屬性則設置控件本身相對于父控件的顯示位置
          android:gravity是本元素所有子元素的重力方向。

          android:layout_gravity="center_vertical"
          android:layout_gravity="left"
          android:layout_gravity="left|bottom"


          TextView中文本字體
          android:text="@String/text1"    //在string.xml中定義text1的值
          android:textSize="20sp"
          android:textColor=”#ff123456”
          android:textStyle="bold"    //普通(normal), 斜體(italic),粗斜體(bold_italic)

          定義控件是否可見
          android:visibility=”visible”     //可見
          android:visibility=”invisible”  //不可見,但是在布局中占用的位置還在
          android:visibility=”gone”   //不可見,完全從布局中消失

          定義背景圖片
          android:background="@drawable/img_bg"    //img_bg為drawable下的一張圖片

          seekbar控件背景圖片及最大值
          android:progressDrawable="@drawable/seekbar_img" 
          android:thumb="@drawable/thumb"           
          android:max = "60"

           

          僅在RelativeLayout中有效:
          在父親布局的相對位置
          android:layout_alignParentLeft="true"     //在布局左邊
          android:layout_alignParentRight="true"    //在布局右邊
          android:layout_alignParentTop="true"     //在布局上面
          android:layout_alignParentBottom="true "  //在布局的下面

          在某個控件的相對位置
          android:layout_toRightOf="@id/button1"  //在控件button1的右邊,不僅僅是緊靠著
          android:layout_toLeftOf="@id/button1"   //在控件button2的左邊,不僅僅是緊靠著
          android:layout_below="@id/button1 "     //在控件button1下面,不僅僅是正下方
          android:layout_above=“@id/button1”   //在控件button1下面,不僅僅是正下方

          定義和某控件對奇
          android:layout_alignTop=”@id/button1”  //和控件button1上對齊
          android:layout_alignBottom=”@id/button1”  //和控件button1下對齊
          android:layout_alignLeft=”@id/button1”  //和控件button1左對齊
          android:layout_alignRight=”@id/button1”  //和控件button2右對齊


          android:layout_centerHorizontal="true"        //水平居中
          android:layout_centerVertical="true"
          android:layout_centerInParent="true"

          僅在LinearLayout中有效
          設置控件在一排或一列中所占比例值
          android:layout_weight="1"



                  本Blog純屬個人學習、工作需要,記錄相關資料。請不要發表任何有人身攻擊的言論,謝謝! www.zhipsoft.cn
          posted on 2011-01-25 17:08 ZhipSoft 閱讀(11375) 評論(3)  編輯  收藏 所屬分類: AndRoid

          FeedBack:
          # re: [摘]android 入門xml布局文件
          2012-08-21 15:51 | cs
          謝謝!  回復  更多評論
            
          # re: [摘]android 入門xml布局文件
          2012-09-08 13:55 | cocoas
          頂頂頂  回復  更多評論
            
          # re: [摘]android 入門xml布局文件
          2013-04-02 10:18 | lhz
          xiexie  回復  更多評論
            
          主站蜘蛛池模板: 西宁市| 新巴尔虎左旗| 广平县| 聊城市| 高陵县| 霍林郭勒市| 盐边县| 林周县| 闸北区| 莱阳市| 汉源县| 新蔡县| 林口县| 伽师县| 云浮市| 宝清县| 襄垣县| 梁河县| 新民市| 玛沁县| 松原市| 华阴市| 丹阳市| 德江县| 镶黄旗| 许昌市| 岢岚县| 临邑县| 博罗县| 柳河县| 宝山区| 慈利县| 云阳县| 湟源县| 扶风县| 津南区| 正宁县| 宜君县| 汝阳县| 阳信县| 开鲁县|