设为首页 加入收藏

TOP

安卓之布局总结(三)
2019-09-01 23:26:16 】 浏览:103
Tags:安卓之 布局 总结
apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/TableLayout2" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TableRow> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="周日" android:background="#00000000"/> #去除button控件的样式 <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="周一" android:background="#00000000"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="周二" android:background="#00000000"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="周三" android:background="#00000000" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="周四" android:background="#00000000"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="周五" android:background="#00000000" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="周六" android:background="#00000000" /> </TableRow> <TableRow> ... ... </TableRow> ... ... ... ... </TableLayout>

 

2. 最后一行“不显示日期”的合并单元格样式

<Button  
       android:layout_width="wrap_content"  
       android:layout_height="wrap_content"  
       android:text="30" />   
            
<Button  
      android:layout_width="wrap_content"  
      android:layout_height="wrap_content" android:layout_span="2"
      android:background="#ffffff" 
      android:text="不显示日期" />   

 

 

(4)绝对布局

绝对布局指定每个控件在手机上的具体坐标,每个控件的位置和大小是固定的。由于不同手机屏幕大小可能不同,所以绝对布局只适用于固定的手机屏幕。平常用得比较少,这里就不做详细介绍了。

 

(5)层布局

层布局也叫帧布局。每个控件占据一层,后面添加的层会覆盖前面的层。如果后面的层的大小大于或者等于前面的层,那么前面的层就会被完全覆盖。后面层中的控件就看不到了。实际应用中如果想要得到一个空间浮现在另一个控件的上方,可以在控件内部嵌套层布局。

下面是层布局的原理图:

 

实例代码:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    
    xmlns:tools="http://schemas.android.com/tools"    
    android:id="@+id/FrameLayout1"    
    android:layout_width="match_parent"    
    android:layout_height="match_parent"    
    tools:context=".MainActivity"      
    android:foregroundGravity="right|bottom">    

    <TextView    
        android:layout_width="200dp"    
        android:layout_height="200dp"    
        android:background="#FF6143" />     //橙色 
    <TextView    
        android:layout_width="150dp"    
        android:layout_height="150dp"    
        android:background="#7BFE00" />     //绿色
     <TextView    
        android:layout
首页 上一页 1 2 3 4 5 下一页 尾页 3/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇一起学Android之ProgressBar 下一篇android 权限库EasyPermissions

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目