Skip to content

Instantly share code, notes, and snippets.

@yunusemredilber
Created February 5, 2020 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yunusemredilber/476bf8b16cb4dfa9d1a9afb28782ace2 to your computer and use it in GitHub Desktop.
Save yunusemredilber/476bf8b16cb4dfa9d1a9afb28782ace2 to your computer and use it in GitHub Desktop.
Android Material FAB With Badge Attached
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_view">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/notifications_button"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="10dp"
app:srcCompat="@drawable/ic_notifications_black_24dp"
android:layout_margin="16dp" />
<TextView
android:layout_width="16dp"
android:layout_height="16dp"
android:elevation="16dp"
android:gravity="center"
android:text="2"
android:background="@drawable/circulo"
android:textColor="@color/grey"
android:textSize="12sp"
app:layout_constraintTop_toTopOf="@id/notifications_button"
app:layout_constraintEnd_toEndOf="@id/notifications_button"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:angle="270"
android:color="@color/grey" />
</shape>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment