设为首页 加入收藏

TOP

Android开发5大布局方式详解(六)
2017-10-13 10:35:47 】 浏览:9826
Tags:Android 开发 布局 方式 详解
sp;  <Button 
  •             android:layout_span="2" 
  •             android:text="Button5" 
  •             /> 
  •     </TableRow> 
  •       
  • </TableLayout> 
  •  
    4.相对布局
    相对布局是按照组件之间的相对位置来布局,比如在某个组件的左边,右边,上面和下面等。
    相对布局常用属性请参考我博客的:http://liangruijun.blog.51cto.com/3061169/631816
     
    简单的例子
    ①效果图:
     
     
    ② 核心代码:
    main.xml
     
    1. <?xml version="1.0" encoding="utf-8"?> 
    2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    3.     android:layout_width="fill_parent" 
    4.     android:layout_height="wrap_content" 
    5.     android:padding="10px" 
    6.     > 
    7.     <TextView    
    8.         android:id="@+id/tev1" 
    9.         android:layout_width="wrap_content"   
    10.         android:layout_height="wrap_content"   
    11.         android:layout_marginBottom="30dp" 
    12.         android:text="Please Type Here:" 
    13.         /> 
    14.     <EditText 
    15.         android:id="@+id/tx1" 
    16.         android:layout_width="match_parent" 
    17.         android:layout_height="wrap_content" 
    18.         android:layout_below="@id/tev1" 
    19.         /> 
    20.     <Button 
    21.         android:id="@+id/btn1" 
    22.         android:layout_height="wrap_content" 
    23.         android:layout_width="wrap_content" 
    24.         android:layout_below="@id/tx1" 
    25.         android:layout_alignParentRight="true" 
    26.         android:text="确定" 
    27.         /> 
    28.     <Button 
    29.         android:id="@+id/btn2" 
    30.   
    首页 上一页 3 4 5 6 7 下一页 尾页 6/7/7
    】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
    上一篇ListFragment的使用 下一篇Android快乐贪吃蛇游戏实战项目开..

    最新文章

    热门文章

    Hot 文章

    Python

    C 语言

    C++基础

    大数据基础

    linux编程基础

    C/C++面试题目