【问题标题】:Elevation for Floating action button is not working浮动操作按钮的高度不起作用
【发布时间】:2019-09-04 01:22:26
【问题描述】:

我正在使用材质组件 FloatingActionButton https://material.io/develop/android/components/floating-action-button/

在那,我无法为我的工厂添加海拔我尝试使用下面的代码,但它不工作 app:elevation="12dp" app:borderWidth="0dp"

这是我的 xml。

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/mfab"
        style="@style/Widget.MaterialComponents.FloatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/mainlay"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="-28dp"
        app:elevation="12dp"
        app:borderWidth="0dp"
        app:fabSize="normal"
        app:srcCompat="@drawable/ic_directions_walk_white_18dp" />

【问题讨论】:

    标签: android material-components material-components-android


    【解决方案1】:

    AFAIK 晶圆厂覆盖海拔值。所以有两种可能的解决方案: 1.你得到fab的源代码并改变海拔值 2. 您创建自己的实现。 我建议您使用第一个解决方案。

    【讨论】:

    • fab的高程值在哪里修改,我尝试通过xml修改但没有成功。
    • @Adarsh 你不能改变晶圆厂的高度
    • @Arthur 你能分享详细的答案吗?
    【解决方案2】:

    您是否尝试过使用所需的高度定义从 Widget.MaterialComponents.FloatingActionButton 继承的自定义样式,并在您的 FAB 实例上设置自定义样式?

    【讨论】:

    • @wcschi 可以分享一下详细答案吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    • 2018-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-02
    • 1970-01-01
    相关资源
    最近更新 更多