Floating Action Button Icon not centered inside

喜夏-厌秋 提交于 2019-12-04 04:42:28

This seems to be a bug in the Design Support Library v28.0.0.

I could workarround this by setting the scaleType programmatically.

In your case in the Java/Kotlin Code:

centerLocationButton.setScaleType(ImageView.ScaleType.CENTER)

My solution is app:fabCustomSize="56dp"

In my situation run ok this solution app:fab_icon="@drawable/btn_back_to_top_3x" enter image description here not android:src="@drawable/btn_back_to_top_3x enter image description here

And you can add android:scaleY="1.X" android:scaleX="1.X"

for additional variation

Instead of android:src try app:srcCompat. Is FAB only thing you are using, because if it is (judging by the pic you posted), maybe you don't need RelativeLayout as a parent, you can use android:layout_gravity="bottom|end"

After updating to SDK 28, I've got the same problem. Changing the size, scaleType, layout_gravity, etc will return the same.

My current short-term solution is using the ImageButton.

Could you try with android:scaleType="center" as a FloatingActionButton property?

user6264291

Try

android:width="wrap_content"
android:height="wrap_content"
app:maxImageSize ="56dp"

on the fab. Worked for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!