如图所示,我的按钮边框上有一个阴影。有没有办法去除阴影,使按钮的颜色与我的操作栏的颜色相对应。就知道它看起来很丑,因为你可以看到阴影。这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TableRow
android:gravity="end">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/logInButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:borderWidth="0dp"
app:backgroundTint="@color/faviconColor"
app:srcCompat="@drawable/ic_person_black_24dp" />
</TableRow>
</TableLayout>
最佳答案
尝试将 android:elevation="0dp"
设置为您的 float 操作按钮。
尽管如此,为什么还要使用 FloatingActionButton 而不是普通按钮? FloatingActionButtons 是 afaik 不能像这样使用,如果你需要,例如圆形波纹效果,还有更优雅的方法可以做到这一点。
编辑:
如果这不起作用(有时),请改用 app:elevation="0dp"
关于Android 从 FloatingActionbutton 移除边框悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56744268/