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列
实例就看文件啦!!!
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列
实例就看文件啦!!!
相关文章推荐
- The project target (Android N (Preview)) was not properly loaded.
- AndroidAutoLayout 屏幕适配
- Android中SQLite数据库小计
- Android——关于Activity跳转的返回(无返回值和有返回值)——无返回值
- Android中Fragment中使用Intent
- Android Smart Image View
- Android学习之友盟开发这些坑
- Android群英传笔记——第五章:Android Scroll分析
- Android群英传笔记——第五章:Android Scroll分析
- Android课程---Activity的跳转与传值(转自网上)
- android studio单元测试
- android--Activity有返回值的跳转
- Android Studio开发环境的配置
- android一连串图片组成动画
- Android课程---Activity中保存和恢复用户状态
- android判断是否禁用了录音权限
- android笔记——android studio环境搭建
- android getDeviceId
- Android问题Button的onClick监听里,如何调用外部类的方法(2048实现重新开始游戏)
- 关于Android的.so文件你所需要知道的