Android 开发之布局细节对比:Gravity相关
好吧,其实本不必写这篇文章,我打算接下来去写源码方面的。之所以写这个,主要是搜了一下网上已有的博客,都是一堆对属性的描述,我只想说,你们能不能上个图啊。
<?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啊。
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
java-工具-开源
什么是开源? 「开源」是从英文「Open Source」翻译精简而来,其实是开放源码的意思,我们知道所有的软件都是由代码编写,经编译生成的系统或者应用。而一旦你把它开源,意味着任何人、任何组织都可以使用你的代码或者软件,当然也可以给你免费贡献代码,优化你的应用,开放源码意味着自由选择的权力,而自由选择意味着激发更多创新的能量。Linux 就是最著名的开源操作系统,而 Java 与 Android 同样也是开源的。 开源社区 开源社区在这两年发展的非常火爆,一些巨头争相加入开源社区,一些常客如Google、Facebook、Square为开源社区贡献了不少优质项目,惊喜的是连苹果、微软等一些比较封闭的公司也竞相加入开源社区,不得不说这是一种好现象,开源也许是软件的未来。 说到开源社区,毫无疑问 GitHub 是目前最大最火爆的开源社区,全球最优秀的程序员与最开放的优秀科技公司都在 GitHub ,你还有什么理由不加入进来呢?本篇所涉及的所有开源项目都指 GitHub 上的开源项目。 为什么要用开源项目? 软件开发领域一直有个原则:DRY,Don’t repeat yourself,翻译过...
- 下一篇
Retrofit--记使用Retrofit时遇到的一个坑
版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/lyhhj/article/details/52098755 绪论 很久没有写博客了,上次是写了使用Retrofit时怎么设置OKHttp,如果你没看到请看: Retrofit–使用Retrofit时怎样去设置OKHttp 你也可以看看我是怎样使用Retrofit的: Retrofit–合理封装回调能让你的项目高逼格 好了,今天说一下我遇到的一个坑吧。 Retrofit Cookie问题 上次我们说过怎么去实现持久化登录,本地保存用户的cookie: 1. 2. 本地新建PersistentCookieStore文件保存SP中 3.添加依赖 compile 'com.squareup.retrofit2:retrofit:2.0.1' compile 'com.squareup.okhttp3:okhttp:3.2.0' compile 'com.squareup.okio:okio:1.6.0' compile 'com.google.code.gson:gson:2.6.2' compile...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- CentOS7,8上快速安装Gitea,搭建Git服务器
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- CentOS关闭SELinux安全模块
- CentOS7设置SWAP分区,小内存服务器的救世主
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- SpringBoot2全家桶,快速入门学习开发网站教程
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题