悬浮按钮FloatingActionButton和提示工具SnackBar是Design Support提供的控件。
悬浮按钮FloatingActionButton及其点击事件:
悬浮按钮FloatingActionButton是不属于主界面平面上的控件,而是位于另一个维度,好像三维坐标上的Z轴。设置它的
app:elevation=""可以设置悬浮高度,值越大,悬浮高,投影大。同时也有点击事件,和普通按钮一样的实现方法。
① 在布局文件添加FloatingActionButton:(这里用了FrameLayout)
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainAct