小编Fer*_*igi的帖子

徽章指向浮动操作按钮

我想在android中 Floating Action Button 前面显示计数徽章.我使用FrameLayout来实现这一目标.我的代码在这里

   <FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/send_button"
    android:layout_toLeftOf="@+id/send_button"
    android:layout_toStartOf="@+id/send_button"
    android:layout_gravity="end|bottom"
    android:id="@+id/frameLayout">

    <android.support.design.widget.FloatingActionButton
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/listen_button"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:backgroundTint="#e3e3e3" />

   <TextView
        android:id="@+id/textOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="10"
        android:textColor="#FFF"
        android:textSize="10sp"
        android:textStyle="bold"
        android:background="@drawable/badge_circle"
        android:layout_gravity="right|bottom"
        android:layout_alignBottom="@+id/frameLayout"
        android:layout_toLeftOf="@+id/frameLayout"
        android:layout_toStartOf="@+id/frameLayout" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

我在FAB下方获得了计数徽章,如下所示

在此输入图像描述

我需要计数徽章在FAB前面.

android android-layout

6
推荐指数
4
解决办法
6754
查看次数

标签 统计

android ×1

android-layout ×1