2019独角兽企业重金招聘Python工程师标准>>>

LinearLayout、RelativeLayout、FrameLayout居中显示需要设置的属性不一样,今天总结下,方便以后使用~~

LinearLayout :android:gravity="center_horizontal"

RelativeLayout : android:layout_centerInParent="true"

FrameLayout :  android:layout_gravity="center"

布局文件如下:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <LinearLayout  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center_horizontal" 
        android:orientation="vertical"> 
        <ImageView  
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:background="@drawable/icon" 
            /> 
    </LinearLayout> 
    <FrameLayout  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"> 
        <ImageView  
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:background="@drawable/icon" 
            android:layout_gravity="center" 
            /> 
    </FrameLayout> 
    <RelativeLayout  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"> 
        <ImageView  
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:background="@drawable/icon" 
            android:layout_centerInParent="true" 
            /> 
    </RelativeLayout> 
</LinearLayout> 
效果如下:

摘自 xiaoxiaobian3310903的专栏

转载于:https://my.oschina.net/mutouzhang/blog/209924

LinearLayout、RelativeLayout、FrameLayout居中显示相关推荐

  1. 【转】RelativeLayout和LinearLayout及FrameLayout性能分析

    原文:http://blog.csdn.net/hejjunlin/article/details/51159419 工作一段时间后,经常会被领导说,你这个进入速度太慢了,竞品的进入速度很快,你搞下优 ...

  2. android 按钮 图片文字居中显示,[Android]Android 布局中如何让图片和文字居中显示?...

    图片文字居中显示 **①组件TextView的属性 drawableTop ``` 块内或者行内图片与文字居中对齐最靠谱的方式! 做图片与文字在一行的按钮时候最常用到,总结了一个靠谱的方法,终于可以完 ...

  3. 扩展Snackbar 使其支持居中显示

    https://github.com/nispok/snackbar 默认Snackbar支持底部或者顶部显示,不支持居中显示 查看Snackbar.java的源码可以看到createMarginLa ...

  4. ScrollView水平滑动条选中条目的居中显示

    创建选择器实现圆角矩形<shape xmlns:android="http://schemas.android.com/apk/res/android"android:sha ...

  5. android imageview 居中显示,Android中ImageView无法居中的问题

    做Android UI布局,尤其是遇到比较复杂的多重LinearLayout嵌套,常常会被一些比较小的问题困扰上半天,比如今天在使用ImageView的时候,想让其居中显示,可是无论怎样设置layou ...

  6. a按钮居中显示 bootstrap_Excel合并后居中,跨越合并,及跨列居中的区别你都知道吗...

    一."合并后居中"我们选择指定行区域,它就在哪个区域进行内容居中. 在"开始"选项卡下的"对齐方式"选项组里点击"合并后居中&qu ...

  7. R语言ggplot2可视化将图像标题(title)居中显示实战

    R语言ggplot2可视化将图像标题(title)居中显示实战 目录 R语言ggplot2可视化将图像标题(title)居中显示实战

  8. 设置div中的div居中显示

    设置div中的div居中显示 方法一. <div class='big'><div class='small'>box1</div></div>styl ...

  9. html中怎么设置文本框居中显示图片,css如何让图片水平居中显示?

    在我们开发前端页面的时候,为了让页面效果美观,会让图片呈现居中效果.那么css怎么让img图片居中显示呢?本篇文章给大家带来css如何让img图片居中. display属性实现图片居中的两种方法: 1 ...

最新文章

  1. 你就是你自己paper最好的审稿人:宾大苏炜杰提出peer review新机制
  2. php动物书总结01-06
  3. Linux 查看CPU,内存,硬盘
  4. JS正则表达式验证账号、手机号、电话和邮箱
  5. 宁波医院计算机试题及答案,(宁波市第25届小学生计算机程序设计竞赛试题及答案.doc...
  6. 山寨版项目管理经验小结
  7. 欢迎大家推荐使用小技巧
  8. velocity 变量 获取_velocity 怎么得到项目根路径
  9. Latex笔记:IEEE Access模板
  10. 2019最新超详细HUSTOJ在线判题系统及Virtual Judge的搭建
  11. Oracle 定时任务执行存储过程
  12. linux scp 拷贝文件
  13. Matplotlib绘图9种经典风格,你喜欢哪种?
  14. 书友汇德天-创作不停,学习不止(十字交叉线画法)
  15. 【成为架构师课程系列】消息队列:秒杀时如何处理每秒上万次的下单请求?
  16. python 做软件授权代理_软件提卡+授权API+代理系统三合一网站源码(开源)
  17. python+word2vec+随机森林 微博文本情感极性分析(一)
  18. 微信读书的 debugger 虽斩断了你的调试的念头,但我有一招
  19. raptor流程图赋值语句_raptor流程图编程
  20. 教你打造基于贝壳内核的最简单一键备份还原软件(源代码)

热门文章

  1. 全向飞行器的设计与制作-学生初步汇报内容
  2. 电视机检测大巴徘徊在英格兰的大街上
  3. 交流线圈磁芯上的短路铜片
  4. AD9833所产生的高频信号质量分析
  5. python pandas for循环_高逼格使用Pandas加速代码,向for循环说拜拜!
  6. FLAC3D可视化后处理matlab,一种基于Matlab的由Midas导入Flac3D的模型识别方法与流程...
  7. java initcause_initCause()是什么意思
  8. ajax回调函数的返回值,使用ajax和回调函数向函数传递/返回值
  9. linux新用户登陆密码,如何强制Linux用户在第一次登录时更改初始密码?
  10. 关于嵌入式开发,到底需要会多少门语言,做好准备了吗