海拔不适用于android.support.design.widget.FloatingActionButton [英] Elevation not working on android.support.design.widget.FloatingActionButton

查看:214
本文介绍了海拔不适用于android.support.design.widget.FloatingActionButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始android开发并尝试新的材料设计. 是我的mainactivity的屏幕截图,其中有一个FloatingActionButton,但没有应用任何高程(没有阴影).

如何在此新窗口小部件(android.support.widget.FloatingActionButton)上启用阴影.

这是来自布局xml的代码

 <android.support.design.widget.FloatingActionButton
        android:id="@+id/add_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_add_action"
        android:layout_margin="16dp"
        android:elevation="10dp"
        android:padding="10dp"/> 

任何帮助表示赞赏.谢谢

请注意,我只想使用android设计库,而不要使用其他任何github库.

解决方案

经过大量研究,我发现使用FAB的正确方法没有问题.使用以下代码作为模板:

<android.support.design.widget.FloatingActionButton
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/your_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="@dimen/floating_button_margin_bottom"
        android:layout_marginRight="@dimen/floating_button_margin_right"
        app:elevation="@dimen/floating_button_elevation"
        app:borderWidth="0dp"
        app:rippleColor="@color/your_ripple_color"
        app:backgroundTint="@color/your_bg_color" />

I've just started android development and trying the new material design. is a screenshot of my mainactivity which has a FloatingActionButton but it doesnt applying any elevation (no shadows).

How can I enable shadow on this new widget (android.support.widget.FloatingActionButton).

This is code from layout xml

<android.support.design.widget.FloatingActionButton
        android:id="@+id/add_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ic_add_action"
        android:layout_margin="16dp"
        android:elevation="10dp"
        android:padding="10dp"/>

Any help appreciated. Thanks

Please note I'd like to use android design library only not any other github libraries.

解决方案

After a lot of research, I've found the proper way to use FAB with no issues. Use the code below as template:

<android.support.design.widget.FloatingActionButton
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/your_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="@dimen/floating_button_margin_bottom"
        android:layout_marginRight="@dimen/floating_button_margin_right"
        app:elevation="@dimen/floating_button_elevation"
        app:borderWidth="0dp"
        app:rippleColor="@color/your_ripple_color"
        app:backgroundTint="@color/your_bg_color" />

这篇关于海拔不适用于android.support.design.widget.FloatingActionButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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