Android M 新控件了解:FloatingActionButton,TextInputLayout,Snackbar,TabLayout, AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout
学习FloatingActionButton,TextInputLayout,Snackbar,TabLayout ,AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout
- FloatingActionButton 这是一个浮动按钮,重写ImageView的,所有FloatingActionButton拥有ImageView的一切属性。
- TextInputLayout 用于EditView输入框, TextInputLayout是继承自LinearLayout容器布局,因此我们需要将EditView包含在TextInputLayout之内才可以使用,言外之意:TextInputLayout不能单独使用。
- Snackbar 提供了一个介于Toast和AlertDialog之间轻量级控件,它可以很方便的提供消息的提示和动作反馈。Snackbar是从整个界面的底部弹出。
- TabLayout Tabs选项卡,效果类似网易新闻客户端的Tab。其实实现Tabs选项卡的效果有很多中方法,Github上也有很多好用的开源控件,只是这次谷歌把它官方化了,使得开发者无需引用第三方库,就能方便的使用。
一般TabLayout都是和ViewPager共同使用才发挥它的优势.
- AppBarLayout 是继承LinerLayout实现的一个ViewGroup容器组件,它是为了Material Design设计的App Bar,支持手势滑动操作。默认的AppBarLayout是垂直方向的,它的作用是把AppBarLayout包裹的内容都作为AppBar。代码将Toolbar 和Tablayout的组合部分共同构成 AppBar的效果:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll"
app:tabIndicatorColor="@android:color/holo_red_dark"
app:tabSelectedTextColor="@android:color/holo_red_dark"
app:tabTextColor="@android:color/black"
/>
</android.support.design.widget.AppBarLayout>
AppBarLayout是支持手势滑动效果的,不过的跟CoordinatorLayout配合使用。
6.CoordinatorLayout----- CoordinatorLayout是一个增强型的FrameLayout。作用:
作为一个布局的根布局 and 作为一个为子视图之间相互协调手势效果的一个协调布局。
CoordinatorLayout是FrameLayout布局,所以可以用android:layout_gravity="bottom|end"属性
7.CollapsingToolbarLayout --CollapsingToolbarLayout包裹 Toolbar 的时候提供一个可折叠的 Toolbar,一般作为AppbarLayout的子视图使用。
8.NavigationView 用于侧滑菜单中的menu布局。具体可以看我上一篇博客的文章
参考链接~十分重要
-
Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用
-
Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用
- 附带一些我之前学习其他控件认为比较好的链接
- Android5.x新特性之 Toolbar和Theme的使用
如果文章给了您帮助,就给我个赞给予一下鼓励吧~