Android的Layout --- 布局

UILayout

LinearLayout 线性布局

  • 默认android:orientation="horizontal" 水平布局
  • layout_gravity 对齐方式 center_vertical 垂直居中center_horizontal 水平居中
    • center
    • bottom
    • top
    • left
    • right
  • weight 比例 - 牢记剩余空间 比例时,width设置0dp

RelativeLayout 相对布局

  • 相对父布局
    • android:layout_alignParentLeft
    • android:layout_alignParentRight
    • android:layout_alignParentTop
    • android:layout_alignParentBotton
    • android:layout_centerInParent
  • 相对控件
    • android:layout_above="@+id/xxxxx"
    • android:layout_blow="@+id/xxxxx"
    • android:layout_toLeftOf="@+id/xxxxx"
    • android:layout_toRightOf="@+id/xxxxx"

FrameLayout 帧布局

  • 全部控件都在左上角,应用很少
  • layout_gravity 对齐方式也可以用 碎片中有应用

百分比布局

  • layout_weight只有在LinearLayout中可以使用,在其他布局很难实现,所以引入百分比布局,直接定义控件所占百分比
  • PercentFrameLayout 和 PercentRelativeLayout

这是我学习Android的笔记,参考书<<第一行代码-第二版>>,感谢郭霖大神
如有不足之处,可以一起讨论
附上郭霖的blog http://blog.csdn.net/guolin_blog

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 177,617评论 25 709
  • 欢迎Follow我的GitHub, 关注我的CSDN. 其余参考Android目录. 转载请注明出处:http:/...
    passiontim阅读 4,932评论 0 31
  • ¥开启¥ 【iAPP实现进入界面执行逐一显】 〖2017-08-25 15:22:14〗 《//首先开一个线程,因...
    小菜c阅读 7,222评论 0 17
  • 寒意袭人枕簟凉,秋风裁尽满庭芳。 从无菡萏曾惜冷,却有芳菊只爱霜。 绿袜佳人朝聚墨,紫衣倩影夜添香。 愿君不弃长相...
    莫愁Jessie阅读 909评论 2 12
  • 爱情需要双方的勇气,一方没有勇气这场爱情的仗也会是全军覆没。 假如我没有勇气,你也没有勇气,未开始前我们就已经输了...
    floater茜阅读 191评论 0 0

友情链接更多精彩内容