Android的大号FAB按钮阴影

编程入门 行业动态 更新时间:2024-10-12 01:24:44
本文介绍了Android的大号FAB按钮阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在材料设计方针谷歌presented 按钮的新样​​式,在 FAB按钮的。我发现,说明如何使它但我有麻烦添加阴影。如何才能实现这一目标?

In the Material Design guidelines Google presented a new style of button, the FAB Button. I found instructions how to make it but I have trouble adding the shadow. How can this be achieved?

推荐答案

查阅activity.java,有可能是你所需要的code。

Check out the "activity.java", there is probably the code you need.

我做了晶圆厂 - 巴顿是这样的:

I made the Fab - Button like this:

layout.xml

<Button style="?android:attr/buttonStyleSmall" android:layout_width="56dp" android:layout_height="56dp" android:text="+" android:textSize="40sp" android:background="@drawable/ripple" android:id="@+id/fabbutton" android:layout_margin="@dimen/activity_horizontal_margin" android:elevation="3dp" android:paddingBottom="16dp" android:fontFamily="sans-serif-light" android:layout_alignParentEnd="true" android:layout_gravity="right|bottom" />

ripple.xml

<?xml version="1.0" encoding="utf-8"?> <ripple android:color="#ffb300" xmlns:android="schemas.android/apk/res/android"> <item android:drawable="@drawable/fab"></item> </ripple>

fab.xml

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="schemas.android/apk/res/android" android:shape="rectangle"> <solid android:color="@color/accentColor" /> </shape>

Activity.java

import android.graphics.Outline; ... Button fab = (Button) rootView.findViewById(R.id.fabbutton); Outline mOutlineCircle; int shapeSize = getResources().getDimensionPixelSize(R.dimen.shape_size); mOutlineCircle = new Outline(); mOutlineCircle.setRoundRect(0, 0, shapeSize, shapeSize, shapeSize / 2); fab.setOutline(mOutlineCircle); fab.setClipToOutline(true);

这code将显示为Android的工作室v0.8.1的错误,从而为其他Android L个分量。这将在下一版本。

This code will be shown as error in android studio v0.8.1, so as other android l components. It will be fixed in the next version.

结果:

更多推荐

Android的大号FAB按钮阴影

本文发布于:2023-11-29 14:00:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646590.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大号   阴影   按钮   Android   FAB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!