1.Android开发常用布局

  1. LinearLayout 【高频】
  2. RelativeLayout 【高频】
  3. FrameLayout 【较少】
  4. FlexboxLayout 【较少】
  5. ConstraintLayout 【中频】
  6. AbsoluteLayout 【极少】
  7. TableLayout 【极少】
  8. GridLayout 【较少】
  9. NestedScrollView 【中频】
  10. HorizontalScrollView【较少】
  11. PercentRelativeLayout 【较少】使用全解->
  12. PercentFrameLayout【较少】使用全解->
  13. PercentLinearlayout 【较少】鸿洋大神github ->

2.开发注意细节

2.1 LinearLayout

android:layout_widthandroid:layout_height是必须属性,子View在使用layout_weight时,子View最好将对应方向的android:layout_width或android:layout_height 值设置为0dpandroid:orientation布局方向是必须属性,默认水平方向,建议单子View时也显式设置方向

2.2 RelativeLayout

~~layout_alignParentLeft~~ : 与父布局左对齐,建议使用layout_alignParentStartlayout_alignParentTop : 与父布局上对齐~~layout_alignParentRight ~~: 与父布局右对齐layout_alignParentBottom : 与父布局下对齐layout_alignParentStart : 为了适配一些从右到左阅读习惯的地区。如适配阿拉伯语,start代表右边,中文是左边。layout_alignParentEnd : 同理取反layout_alignParentStart同理其他marginLeft/marginRight 建议改用 marginStart/ marginEnd

2.3 ScrollView

建议直接使用NestedScrollView ,用法相同,NestedScrollView方便MD风格改动android:layout_width只能是match_parent或具体数值,不能是wrap_content;

2.3 HorizontalScrollView

android:layout_height只能是match_parent或具体数值,不能是wrap_content;

2.4 ConstraintLayout

* 不建议在列表子项使用该布局:ConstraintLayout不适合在列表类的item布局文件中作为根标签使用,列表类滚动时,会出现绘制错误。也不建议在布局中常用,因为各种id强关联,牵一发动全身,遇上朝令夕改的产品经理,会改出血丝眼

更多相关文章

  1. Android学习笔记―第十一章 Fragment
  2. Android使用Application总结
  3. Android(安卓)手势识别向左,右,上,下,滑动的方向
  4. android 固定横屏幕竖屏
  5. Android(安卓)popupWindow的使用
  6. Android(安卓)Jetpack之CameraX使用
  7. 箭头函数的基础使用
  8. NPM 和webpack 的基础使用
  9. Python list sort方法的具体使用

随机推荐

  1. (翻译)又一个Android(安卓)Sqlite库: Cup
  2. TabHost与RadioGroup结合完成的菜单
  3. 数据存储和界面笔记
  4. Android手势监听类GestureDetector
  5. Android学习之 UI效果
  6. Android的相对布局属性的解释
  7. Android中Activity启动模式详解
  8. ImageView的android:maxHeight,android:mi
  9. android contentResolver的使用
  10. Android(安卓)editText(文本框) 的基本属性