我的FloatingActionButton在4.4及以下版本中出现了一些奇怪的行 [英] My FloatingActionButton has some weird lines coming out of it on 4.4 and lower

查看:92
本文介绍了我的FloatingActionButton在4.4及以下版本中出现了一些奇怪的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述,我的FloatingActionButton仅在4.4或更低版本上出现了一些奇怪的行.在棒棒糖上,它可以正常工作.

As the title says, my FloatingActionButton has some weird lines coming out of it only on 4.4 or lower. On Lollipop it works fine.

这是问题的图片:

播放图像中没有这些行.我的xml:

The play image doesn't have those lines in it. My xml:

<android.support.design.widget.FloatingActionButton
            android:id="@+id/play"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:src="@drawable/ic_av_play_arrow"
            app:borderWidth="0dp"
            app:elevation="6dp"
            app:layout_anchor="@+id/image"
            app:layout_anchorGravity="center_vertical|right|end"
            app:rippleColor="@color/color_primary_light" />

那我在做什么错了?

如果我将海拔高度设置为0dp,则会消失,所以我认为我只会在较旧的手机上这样做

goes away if I set my elevation to 0dp so I think I'll do that just for older phones

推荐答案

您的问题是,您使FloatingActionButton的大小超出了预期.支持库中的FloatingActionButton仅支持两种大小,必须使用fabSize属性进行设置.

Your problem here is that you're making the FloatingActionButton an unexpected size. The FloatingActionButton in the support library only supports two sizes, and it must be set using the fabSize attribute.

您应该更改:

<android.support.design.widget.FloatingActionButton
            android:id="@+id/play"
            android:layout_width="48dp"
            android:layout_height="48dp"

成为:

<android.support.design.widget.FloatingActionButton
            android:id="@+id/play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

如果您想要较小的版本:

If you want a smaller version:

<android.support.design.widget.FloatingActionButton
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fabSize="mini"

来源: http://developer.android.com/参考/android/support/design/widget/FloatingActionButton.html

这篇关于我的FloatingActionButton在4.4及以下版本中出现了一些奇怪的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆