Android的大号FAB按钮阴影大号、阴影、按钮、Android

由网友(让硪静一静)分享简介:在材料设计方针谷歌presented 按钮的新样​​式,在 FAB按钮的。我发现,说明如何使它但我有麻烦添加阴影。如何才能实现这一目标?In the Material Design guidelines Google presented a new style of button, the FAB Button. I...

在材料设计方针谷歌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="http://schemas.android.com/apk/res/android">
 <item android:drawable="@drawable/fab"></item>
</ripple>

fab.xml

<?xml version="1.0" encoding="utf-8"?>
  <shape xmlns:android="http://schemas.android.com/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.

结果:

阅读全文

相关推荐

最新文章