新的浮动操作按钮应为56dp x 56dp,其中的图标应为24dp x 24dp。所以图标和按钮之间的间距应该是16dp。
<ImageButton
android:id="@+id/fab_add"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="bottom|right"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:background="@drawable/ripple_oval"
android:elevation="8dp"
android:src="@drawable/ic_add_black_48dp" />
ripple_oval.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item>
<shape android:shape="oval">
<solid android:color="?android:colorAccent" />
</shape>
</item>
</ripple>
这是我得到的结果:
我使用了来自\material-design-icons-1.0.0\content\drawable-hdpi\ic_add_black_48dp.png的图标
https://github.com/google/material-design-icons/releases/tag/1.0.1
如何使按钮内的图标的大小精确到指南中所述的?
http://www.google.com/design/spec/components/buttons.html#buttons-floating-action-button
发布于 2014-12-15 20:41:53
由于您的内容是24dp x 24dp,因此您应该使用24dp icon。然后在ImageButton中设置android:scaleType="center"
,以避免自动调整大小。
发布于 2018-09-03 15:28:08
在将支持库更新到v28.0.0之后,尝试使用app:maxImageSize="56dp"
而不是上面的答案
发布于 2016-06-24 13:28:47
在dimens中输入此条目
<!--Floating action button-->
<dimen name="design_fab_image_size" tools:override="true">36dp</dimen>
这里36dp是浮点按钮上的图标大小。这将为浮动操作按钮的所有图标设置36dp大小。
根据评论更新
如果你想将图标大小设置为特定的浮动动作按钮,只需使用浮动动作按钮的属性,如app:fabSize="normal“和android:scaleType=”app:fabSize=“。
<!--app:fabSize decides size of floating action button You can use normal, auto or mini as per need-->
app:fabSize="normal"
<!--android:scaleType decides how the icon drawable will be scaled on Floating action button. You can use center(to show scr image as original), fitXY, centerCrop, fitCenter, fitEnd, fitStart, centerInside.-->
android:scaleType="center"
https://stackoverflow.com/questions/27484126
复制相似问题