Android : FloatingActionButton の xml
ポイント
- フルパス指定しないと inflate error.
- ネームスペースを追加(xmlns:app="http://schemas.android.com/apk/res-auto")
- app:elevation で Z位置(=影の広がりの大きさ)を指定
- 併せて app:boarderWidth="0dp" をセットしないと elevation による影が出ないので注意
- app:backgroundTint でボタン色を指定(デフォルトは Theme の accent)
- app:rippleColor でボタンを押した時の色を指定
- app:fabSize="mini" とするとボタンが小さくなる
- app:pressedTranslationZ で押された際のボタンの Z 位置を指定(大きくすると、ボタンを押した時に影の広がりが大きくなることがわかる)
サンプル
<android.support.design.widget.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginRight="16dp" android:layout_marginBottom="16dp" android:src="@drawable/ic_mode_edit_white_48dp" app:borderWidth="0dp" app:elevation="4dp"/>