Android MVP 项目分析
Material Designer布局
1.activity_main.xml
布局分为:
- 根布局 DrawerLayout。
- 主内容页面 navigation_content.xml。
- 侧拉菜单布局 NavigationView 必须给侧拉菜单设置 。android:layout_gravity=”start”,这样才能让根布局知道NavigationView 是侧拉菜单。
2 navigation_content.xml 从名字看出这个ViewGroup是用来协调它的子View的
布局分为:
- 根局部 CoordinatorLayout
AppBarLayout 是CoordinatorLayout的子布局,AppBarLayout是一个LinearLayout,它的子View默认纵向排列, 可以通过一些参数控制子View的滑动行为。layout_scrollFlags(scroll,enterAlways,enterAlwaysCollapsed,snap,exitUntilCollapsed)
scroll
1. 先滚动scollerView,在滚动这个view 2. 其他的flag都要和scroll这个flag配合使用。要不会失效
enterAlways
1. 无论怎么滚动,设置flag为enterAlways的view都先滚动
enterAlwaysCollapsed
enterAlways的附加值。这里涉及到Child View的高度和最小高度。设置flag为scroll|enterAlways|enterAlwaysCollapsed的view 1. 下拉 1.1 都先滚动到minHeight, 1.2 然后Scrolling View开始移动到边界 1.3 Child View再向下滚动,直至显示到layout_height。 2. 上拉 2.1 Child View直接进去 ... android:layout_height="@dimen/dp_200" android:minHeight="@dimen/dp_56" ... app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" ...
exitUntilCollapsed
这里也涉及到最小高度。发生向上滚动事件时,Child View向上滚动退出直至最小高度,然后Scrolling View开始滚动。 也就是,Child View不会完全退出屏幕。
snap
添加吸附效果。For example, if the view only has it's bottom 25% displayed, it will be scrolled off screen completely. Conversely, if it's bottom 75% is visible then it will be scrolled fully into view.