问题描述
我想通过自定义宽度和高度将我的FloatingActionButton
变得更大.我发现只有在FrameLayout
或CoordinatorLayout
中将其添加为子级时,才有可能.在棒棒糖和棉花糖上看起来不错.但是在棒棒糖之前,来自FloatingActionButton
的阴影非常奇怪.是来自Android的错误还是我做错了什么?
I want to make my FloatingActionButton
much bigger with custom width and height. I find out that this is possible only if I add this as a child in FrameLayout
or in CoordinatorLayout
. On Lollipop and Marshmallow it looks good. But on pre-Lollipop the shadow from FloatingActionButton
is very strange. Is it a bug from Android or I did something wrong?
<android.support.design.widget.CoordinatorLayout
android:id="@+id/help_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<android.support.design.widget.FloatingActionButton
android:id="@+id/my_btn"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:src="@mipmap/ic_launcher" />
</android.support.design.widget.CoordinatorLayout>
我也尝试添加和app:borderWidth="0dp"
,但是没有运气.
I also tried to add and app:borderWidth="0dp"
but with no luck.
这是奇巧(Kitkat)的样子:
This is how it looks in Kitkat:
推荐答案
Fab按钮在两个默认尺寸下可用.普通(56dp),迷你(40dp)
Fab button is available under two default dimensions.Normal (56dp),Mini (40dp)
但是您可以通过在dimens.xml中(在值下方)添加以下代码来覆盖此值.
But you can override this values by adding followings code in dimens.xml (under values).
<dimen name="design_fab_size_normal">150dp</dimen>
<dimen name="design_fab_size_mini">30dp</dimen>
这篇关于棒棒糖上的FloatingActionButton阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!