Android Material风格的应用(四)--FloatActionButton
2016-11-14 13:48
337 查看
添加 FloatActionButton和SnackBar
Android Material风格的应用(一)–AppBar TabLayoutAndroid Material风格的应用(二)–RecyclerView
Android Material风格的应用(三)–DrawerLayout
Android Material风格的应用(四)–FloatActionButton
Android Material风格的应用(五)–CollapsingToolbar
![](http://upload-images.jianshu.io/upload_images/2972448-55f9adb0d88d20cc.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
工程源码
在
activity_main.xml中的
CoordinatorLayout中添加
FloatActionButton
<android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/fab" android:layout_gravity="right|bottom" android:layout_marginBottom="@dimen/md_keylines" android:layout_marginRight="@dimen/md_keylines" android:src="@drawable/ic_add"/>
在
MainActivity.java中添加逻辑处理,fab点击时显示
Snackbar
FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Snackbar.make(v,"This is Snackbar!!",Snackbar.LENGTH_LONG).show(); } });
相关文章推荐
- Android Material风格的应用(四)--FloatActionButton
- Android Material风格的应用(四)--FloatActionButton
- No resource found that matches the given name 'android:Widget.Material.ActionButton'.
- No resource found that matches the given name 'android:Widget.Material.ActionButton'
- Android Material风格的应用(三)--DrawerLayout
- android 使用FloatActionButton(FAB)悬浮按钮问题
- 导入android-support-v7-appcompat出现问题: android:Widget.Material.ActionButton
- Android Material风格的应用(二)--RecyclerView
- Android Material风格的应用(五)--CollapsingToolbar
- No resource found that matches the given name 'android:Widget.Material.ActionButton'的原因及解决方法
- Android Material风格的应用(一)--AppBar TabLayout
- ECLIPSE使用appcompat_v7库无法找到android:Widget.Material.ActionButton的问题
- Android Material风格的应用(五)--CollapsingToolbar
- 导入android-support-v7-appcompat出现问题: android:Widget.Material.ActionButton
- android 悬浮按钮 FloatActionButton
- Android Material风格的应用(五)--CollapsingToolbar
- Android Study Material Design 十二 之 FloatingActionButton初识
- Android Material风格的应用(二)--RecyclerView
- Android Material风格的应用(三)--DrawerLayout
- Android中Material Desgin风格的Snackbar、TextInputLayout、FloatingActionButton使用