- View
-
has width, height, background, and can be made interactive
-
TextView , Image view, button
-
Unit: dp(density independent Pixel)
-
Linear layout有水平和垂直布局
-
Constraint layout:
best for 安排small num of views
-
ScrollView
- 只能包含一个其他的layout, 通常是LinearLayout
-
Data Binding
- 如果一直用findviewbyid来找控件的话, 会很复杂。因为这个命令是在运行(runtime)的时候再依次执行,如果东西多来就会很慢
- so,通过layout file就可以在compile time的时候链接 activity和fragment— 通过创建一个类来实现
Step:
- Enable data binding in your build.gradle file in the app module inside the android section:
dataBinding { enable = true } -
Constraint Layout
-
Chain
-
Baseline Constraint
用来设置当字体大小不一致时候当layout处理
Layout
style override theme
Dimens & Dimensions
allow u to specify reusable measurements for ur app
- dp for 各种边距, sp for font size