菜鸟相对布局笔记

来源:互联网 发布:java ip查地区 编辑:程序博客网 时间:2024/06/05 07:56
1 .<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"  
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"                      
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:padding="30px"                      定义各控件离边框的距离
    tools:context=".MainActivity" >


    <TextView 
        android:id="@+id/label"                               为文字加入类内部
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="点击我" />                               
    <EditText 
        android:id="@+id/labol"                               
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:drawable/editbox_background"              定义背景颜色
        android:layout_below="@id/label"                           layout below 在某某的下面      @id/label    此组键代表 TextView  ,此文本定义在此组键的下边,
        
        />
    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/labol"                    文字定义在文本框的下边
        android:id="@+id/entry"                                 
        android:layout_alignParentRight="true"               定义在父界面的右边
        android:layout_marginLeft="10px"                         定义此组键左边的间距
        android:text="OK"                                             
        />


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/entry"                          与组键Entry同高
        android:layout_alignBottom="@+id/entry"                                  与组键同大小
        android:layout_toLeftOf="@+id/entry"                       在组建的左边
        android:text="Concel" />


</RelativeLayout>


2.<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"


    android:id="@+id/root"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="30px"       界面离实际内容距离
    >
    <RelativeLayout                                              嵌套相对布局
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"                          此时高度只能包裹内容的高度
         >      
        <TextView                                                                   
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="请输入手机号码:"
        android:layout_alignParentLeft="true"                 定义在容器的左边
        android:padding="20px"                               间距20px
         />
     <EditText 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/text"                      定义在某某的右边
        android:layout_alignLine="@id/text"                 与button同一水平线   
        android:id="@+id/number"                                 
         />
        ></RelativeLayout>
     <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="请输入内容:" />
     <EditText 
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:minLines="3"
        android:id="@+id/content"
     />
     <Button 
         android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="发送"
        android:id="@+id/button"
         />


</LinearLayout>

0 0
原创粉丝点击