您的位置:首页 > 移动开发 > Android开发

android的常用布局LinearLayout和RelativeLayout

2016-03-21 23:48 525 查看
RelativeLayout:

android:layout_centerInParent="true";控件在父类容器正中间

android:layout_centerHorizontal="true";控件与父类水平中心

android:layout_centerVertical="true";控件与父类垂直中心

android:layout_alignParentTop="true"控件在父类的上边

android:layout_toRightOf="id";在哪一个控件的右边

android:layout_above="id";在哪一个控件的上边

android:layout_alignRight="id";与哪一个控件右边对齐

LinearLayout:

<LinearLayout 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"

tools:context="com.example1.work_2.MainActivity"

android:orientation="horizontal" >:控件布局是水平还是垂直

android:layout_gravity="bottom";控件在父类的位置

android:gravity="center";控件内部文字位置

android:layout_weight="1";占地方的比重

TableLayout:

全局属性:

<?xml version="1.0" encoding="utf-8"?>

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

android:layout_width="match_parent"

android:layout_height="match_parent"

android:stretchColumns="1"

android:shrinkColumns="0">

<!-- stretchColumns:第几列可伸展 -->

<!-- shrinkColumns:第几列可收缩 -->

控件属性:

android:layout_column="1" 该控件显示在第1列

android:layout_span="2" 该控件占据2列

实例就看文件啦!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: