floatingactionbutton src图标不居中解决
1.不居中用法
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floating_add_key"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:backgroundTint="@color/green"
android:src="@mipmap/add"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
展示
2.修改后
在布局属性中加入
app:fabCustomSize=“50dp”
这个属性还能定义圈的大小
代码:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floating_add_key"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:backgroundTint="@color/build_new_key"
android:src="@mipmap/ic_ico_add_key"
app:fabCustomSize="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
展示