博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android横竖屏自适应ScrollView及Button组居中布局
阅读量:4320 次
发布时间:2019-06-06

本文共 3723 字,大约阅读时间需要 12 分钟。

    界面如下:

   

    可以根据需要进行扩展,layout代码如下:

   

<?
xml version="1.0" encoding="utf-8"
?>
<
ScrollView 
xmlns:android
="http://schemas.android.com/apk/res/android"
    android:layout_width
="fill_parent"
    android:layout_height
="fill_parent"
 
>
    
<
LinearLayout
        
android:layout_width
="fill_parent"
        android:layout_height
="wrap_content"
        android:gravity
="center"
        android:orientation
="vertical"
 
>
        
<
RelativeLayout
            
android:layout_width
="wrap_content"
            android:layout_height
="wrap_content"
            android:paddingTop
="20dp"
            android:paddingBottom
="20dp"
 
>
            
<
Button
                
android:id
="@+id/btn1"
                android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:text
="测试按钮01"
 
/>
            
<
Button
                
android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:layout_marginLeft
="50dp"
                android:layout_toRightOf
="@id/btn1"
                android:text
="测试按钮02"
 
/>
        
</
RelativeLayout
>
        
<
RelativeLayout
            
android:layout_width
="wrap_content"
            android:layout_height
="wrap_content"
            android:paddingBottom
="20dp"
 
>
            
<
Button
                
android:id
="@+id/btn2"
                android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:text
="测试按钮03"
 
/>
            
<
Button
                
android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:layout_marginLeft
="50dp"
                android:layout_toRightOf
="@id/btn2"
                android:text
="测试按钮04"
 
/>
        
</
RelativeLayout
>
        
<
RelativeLayout
            
android:layout_width
="wrap_content"
            android:layout_height
="wrap_content"
            android:paddingBottom
="20dp"
 
>
            
<
Button
                
android:id
="@+id/btn3"
                android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:text
="测试按钮05"
 
/>
            
<
Button
                
android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:layout_marginLeft
="50dp"
                android:layout_toRightOf
="@id/btn3"
                android:text
="测试按钮06"
 
/>
        
</
RelativeLayout
>
        
<
RelativeLayout
            
android:layout_width
="wrap_content"
            android:layout_height
="wrap_content"
            android:paddingBottom
="20dp"
 
>
            
<
Button
                
android:id
="@+id/btn4"
                android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:text
="测试按钮07"
 
/>
            
<
Button
                
android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:layout_marginLeft
="50dp"
                android:layout_toRightOf
="@id/btn4"
                android:text
="测试按钮08"
 
/>
        
</
RelativeLayout
>
        
<
RelativeLayout
            
android:layout_width
="wrap_content"
            android:layout_height
="wrap_content"
            android:paddingBottom
="20dp"
 
>
            
<
Button
                
android:id
="@+id/btn5"
                android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:text
="测试按钮09"
 
/>
            
<
Button
                
android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:layout_marginLeft
="50dp"
                android:layout_toRightOf
="@id/btn5"
                android:text
="测试按钮10"
 
/>
        
</
RelativeLayout
>
        
<
RelativeLayout
            
android:layout_width
="wrap_content"
            android:layout_height
="wrap_content"
            android:paddingBottom
="20dp"
 
>
            
<
Button
                
android:id
="@+id/btn6"
                android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:text
="测试按钮11"
 
/>
            
<
Button
                
android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:layout_marginLeft
="50dp"
                android:layout_toRightOf
="@id/btn6"
                android:text
="测试按钮12"
 
/>
        
</
RelativeLayout
>
        
<
RelativeLayout
            
android:layout_width
="wrap_content"
            android:layout_height
="wrap_content"
            android:paddingBottom
="20dp"
 
>
            
<
Button
                
android:id
="@+id/btn7"
                android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:text
="测试按钮13"
 
/>
            
<
Button
                
android:layout_width
="wrap_content"
                android:layout_height
="wrap_content"
                android:layout_marginLeft
="50dp"
                android:layout_toRightOf
="@id/btn7"
                android:text
="测试按钮14"
 
/>
        
</
RelativeLayout
>
    
</
LinearLayout
>
</
ScrollView
>

 

    转载请注明出处,网址:

转载于:https://www.cnblogs.com/waterfrost/archive/2012/06/05/2536395.html

你可能感兴趣的文章
adobe flash player升级coredump分析
查看>>
pycharm快捷键、经常使用设置、配置管理
查看>>
element-ui table 最后一行合计,单元格合并
查看>>
.NET 常用加密、解密& 数字签名算法
查看>>
开博声明
查看>>
FileReader读取文件
查看>>
逆向-攻防世界-re2-cpp-is-awesome
查看>>
Oracle分割字符串 REGEXP_SUBSTR用法
查看>>
O/R Mapping实际开发经验之谈(转)
查看>>
今天才知道原来我还没弄清楚js中全局变量和局部变量的定义...
查看>>
用户心理特征
查看>>
【z05】聪明的质检员
查看>>
【5001】n皇后问题
查看>>
【codeforces 796D】Police Stations
查看>>
数据库事务与锁详解
查看>>
linux 配置ssh免密码登录
查看>>
《重构》的读后感
查看>>
MySQL索引分析和优化
查看>>
DB2中通用的存储进程分页法度典范
查看>>
Fetchmail 6.3.8
查看>>