当前位置: 首页 > news >正文

Android 开发之布局细节对比:Gravity相关

版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/52098702

好吧,其实本不必写这篇文章,我打算接下来去写源码方面的。之所以写这个,主要是搜了一下网上已有的博客,都是一堆对属性的描述,我只想说,你们能不能上个图啊。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:text="第一个文本"
        android:textSize="20sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>

    <Button
        android:text="第二个文本"
        android:textSize="20sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"/>

    <Button
        android:text="第三个文本"
        android:textSize="20sp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="fill_horizontal"/>

    <Button
        android:text="第四个文本"
        android:textSize="20sp"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:gravity="right"/>

    <Button
        android:text="第五个文本"
        android:textSize="20sp"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:layout_gravity="right"/>

    <Button
        android:text="第六个文本"
        android:textSize="20sp"
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:gravity="right"
        android:layout_gravity="right"/>

    <Button
        android:text="第七个文本"
        android:textSize="20sp"
        android:layout_width="200dp"
        android:layout_height="80dp"
        android:gravity="right|bottom"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <Button
            android:text="第八个文本"
            android:textSize="20sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"/>
    </LinearLayout>
</LinearLayout>

未开启RTL时:

这里写图片描述

开启RTL时:

这里写图片描述

关于RTL可以看这个:Android 开发之布局细节对比:RTL模式

有一个小Demo,托管到GitHub上了,布局相关的博客代码都放到这一个工程下面了,欢迎大家Star啊。

GitHub AndroidLayout

相关文章:

  • 纯Html+Ajax和JSP两者对比的个人理解
  • LEAVE LIST-PROCESSING和LEAVE TO LIST-PROCESSING事件的作用
  • 开根号研究
  • CCIE学习笔记 ----BGP
  • 什么是内存泄漏
  • Log4Net使用指南 - sema - 博客园
  • CentOS运行级别和开机过程
  • 道格拉斯-普克 抽稀算法 附javascript实现
  • jQuery效果-淡入淡出
  • AWSCLI安装及使用
  • iOS - AsyncSocket 的使用
  • 深入了解Java程序执行顺序
  • 4.ASCII码排序
  • 如何对system.img和userdata.img解包,再重新打包
  • UML在软件开发中各个阶段的作用和意义
  • Angular6错误 Service: No provider for Renderer2
  • C++类的相互关联
  • CentOS7 安装JDK
  • css的样式优先级
  • If…else
  • Javascript弹出层-初探
  • Java精华积累:初学者都应该搞懂的问题
  • npx命令介绍
  • Python3爬取英雄联盟英雄皮肤大图
  • SQLServer之创建数据库快照
  • SQLServer之创建显式事务
  • text-decoration与color属性
  • ubuntu 下nginx安装 并支持https协议
  • 得到一个数组中任意X个元素的所有组合 即C(n,m)
  • 技术攻略】php设计模式(一):简介及创建型模式
  • 力扣(LeetCode)21
  • 猫头鹰的深夜翻译:JDK9 NotNullOrElse方法
  • 如何利用MongoDB打造TOP榜小程序
  • 如何优雅的使用vue+Dcloud(Hbuild)开发混合app
  • 思考 CSS 架构
  •  一套莫尔斯电报听写、翻译系统
  • 好程序员大数据教程Hadoop全分布安装(非HA)
  • 积累各种好的链接
  • ​iOS安全加固方法及实现
  • # 透过事物看本质的能力怎么培养?
  • #使用清华镜像源 安装/更新 指定版本tensorflow
  • (007)XHTML文档之标题——h1~h6
  • (10)STL算法之搜索(二) 二分查找
  • (11)MATLAB PCA+SVM 人脸识别
  • (2)nginx 安装、启停
  • (aiohttp-asyncio-FFmpeg-Docker-SRS)实现异步摄像头转码服务器
  • (ZT)薛涌:谈贫说富
  • (分类)KNN算法- 参数调优
  • (经验分享)作为一名普通本科计算机专业学生,我大学四年到底走了多少弯路
  • (免费领源码)python+django+mysql线上兼职平台系统83320-计算机毕业设计项目选题推荐
  • (原創) 如何使用ISO C++讀寫BMP圖檔? (C/C++) (Image Processing)
  • (转)Sublime Text3配置Lua运行环境
  • (转)原始图像数据和PDF中的图像数据
  • .NET Conf 2023 回顾 – 庆祝社区、创新和 .NET 8 的发布
  • .Net IE10 _doPostBack 未定义