您现在的位置是:首页 > 文章详情

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

日期:2016-08-01点击:445
版权声明:转载请联系本人,感谢配合!本站地址: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

原文链接:https://yq.aliyun.com/articles/631307
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章