自定义浮动操作按钮

时间:2018-07-08 16:51:38

标签: android floating-action-button

请帮帮我。 我该怎么做晶圆厂。 我必须使用的是我可以做到的。 也许您知道,我可以阅读我的问题吗?

是否有任何样本/示例可以进行这种转换?

我尝试使用背景,但是没有用

enter image description here

1 个答案:

答案 0 :(得分:0)

制作此视图时出现问题。

  • FloatingActionButton隐藏其上的所有视图。因此,您的点视图不能放在FAB上。因此,我们必须制作ImageView而不是FAB。

将此放置在您的布局中。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@drawable/blue_circle"
        android:padding="15dp"
        android:src="@mipmap/ic_launcher" />

    <ImageView
        android:layout_width="13dp"
        android:layout_height="13dp"
        android:layout_gravity="top|right"
        android:src="@drawable/red_circle" />

</FrameLayout>

res>drawable>blue_circle_gradient.xml

中创建新的xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <gradient
        android:endColor="#8e81fc"
        android:startColor="#7264EA" />
</shape>

res>drawable>red_circle.xml

中创建新的xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#ff0000" />
</shape>

输出将如下所示:

image

相关问题