我正在尝试使用 FAB,但里面的图标位于按钮的右下角:
这是 xml 中的 FAB 定义:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/centerLocationButton"
style="@style/Widget.MaterialComponents.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/pro_arriving_map_location_button_padding"
android:src="@drawable/ic_my_location"
app:backgroundTint="@color/white"
app:fabSize="mini" />
</RelativeLayout>
我做错了什么?
最佳答案
这似乎是设计支持库 v28.0.0 中的错误。
我可以通过以编程方式设置 scaleType 来解决这个问题。
在您的 Java/Kotlin 代码中:
centerLocationButton.setScaleType(ImageView.ScaleType.CENTER)
关于android - float 操作按钮图标未在内部居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52635233/