脸萌2 首页布局

来源:互联网 发布:网络攻防技术 课本 编辑:程序博客网 时间:2024/05/11 18:08

   今天最主要完成的是布局,明天就要完成监控。好激动啊

来整理下

1、线性布局  LinearLayout     控件从上到下排列或者从左到右排列
2、相对布局  RelativeLayout   根据参考物来设置相对位置
3、帧布局    FrameLayout      每个控件,独占一层
4、表格布局  TableLayout      可以制作表格
5、绝对布局  AbsoluteLayout   根据坐标点来确定屏幕位置(地图、2D图形绘制)




RelativeLayout:


1、表示当前控件和父容器之间的位置关系:
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"




2、控件和控件之间表示方位的位置关系:
android:layout_above="@+id/center"
android:layout_below="@+id/center"
android:layout_toRightOf="@+id/center"
android:layout_toLeftOf="@+id/center"


3、控件和控件之间表示对齐的位置关系
android:layout_alignTop="@+id/center"
android:layout_alignBottom="@+id/center"
android:layout_alignRight="@+id/center"
android:layout_alignLeft="@+id/center"




4、控件和空间之间的距离关系
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:layout_marginBottom="10dip"
android:layout_marginLeft="10dip"
android:layout_margin="10dip"


5、控件和内部内容之间的位置关系
android:gravity="right|center_vertical"




6、控件和内部内容之间的距离关系
android:paddingRight="20dip"
android:paddingLeft="20dip"
android:paddingTop="20dip"
android:paddingBottom="20dip"
android:padding="20dip"




控件和内部内容之间位置关系



<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"
    tools:context=".MainActivity" >
    <!-- 整体两个布局 
    相对布局   线性布局 -->
    <!-- 线性布局中又有三个线性布局 -->
     <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/image_sound"
            android:layout_alignParentLeft="true"
            android:src="@drawable/bt_homepage_sound_on"
           />
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/image_reply"
            android:layout_alignParentRight="true"
            android:src="@drawable/bt_yijianfankui_up"
            />
    </RelativeLayout>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:src="@drawable/pic_startpage_logo"
                />
        </RelativeLayout>
     <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
         
     
            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                >
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/bt_man_up"
                    android:id="@+id/bt_man_up"/>
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/bt_woman_up"
                    android:id="@+id/bt_woman_up"
                    android:layout_toRightOf="@+id/bt_man_up"/>


            </RelativeLayout>
            </RelativeLayout>
        
            <RelativeLayout 
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                >
                 <RelativeLayout 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                >
                <ImageButton 
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:src="@drawable/bt_gift_up"
                    android:id="@+id/zhuanshut"
                     android:layout_centerHorizontal="true"
                    android:layout_marginTop="50dip"
                    />
                <ImageButton 
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:src="@drawable/bt_more_up"
                    android:id="@+id/more"
                     android:layout_centerHorizontal="true"
                    />
                
            </RelativeLayout>
            
   </RelativeLayout>
    </LinearLayout>




</RelativeLayout>






稍后把文件上传。埋头做事。



0 0
原创粉丝点击