Badge count on Floating action button
I would like to show count badge in front of Floating Action Button in android. I used FrameLayout in order to achieve that. My code is here
<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>
I get the count badge below the FAB, as shown below
I need the count badge to be in front of the FAB.
android android-layout
add a comment |
I would like to show count badge in front of Floating Action Button in android. I used FrameLayout in order to achieve that. My code is here
<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>
I get the count badge below the FAB, as shown below
I need the count badge to be in front of the FAB.
android android-layout
From the design guidelines: "Floating action buttons don’t contain app bar icons or status bar notifications. Don’t layer badges or other elements over a floating action button." google.com/design/spec/components/…
– Daniel Nugent
Jun 5 '16 at 8:14
Tryandroid:layout_alignParentTop="true"
andandroid:layout_alignParentLeft="true"
for both elements.
– Ali Sheikhpour
Jun 5 '16 at 8:16
add a comment |
I would like to show count badge in front of Floating Action Button in android. I used FrameLayout in order to achieve that. My code is here
<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>
I get the count badge below the FAB, as shown below
I need the count badge to be in front of the FAB.
android android-layout
I would like to show count badge in front of Floating Action Button in android. I used FrameLayout in order to achieve that. My code is here
<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>
I get the count badge below the FAB, as shown below
I need the count badge to be in front of the FAB.
android android-layout
android android-layout
edited Jun 5 '16 at 8:33
Håken Lid
10.8k62643
10.8k62643
asked Jun 5 '16 at 7:57
Feras AlTuraigiFeras AlTuraigi
3113
3113
From the design guidelines: "Floating action buttons don’t contain app bar icons or status bar notifications. Don’t layer badges or other elements over a floating action button." google.com/design/spec/components/…
– Daniel Nugent
Jun 5 '16 at 8:14
Tryandroid:layout_alignParentTop="true"
andandroid:layout_alignParentLeft="true"
for both elements.
– Ali Sheikhpour
Jun 5 '16 at 8:16
add a comment |
From the design guidelines: "Floating action buttons don’t contain app bar icons or status bar notifications. Don’t layer badges or other elements over a floating action button." google.com/design/spec/components/…
– Daniel Nugent
Jun 5 '16 at 8:14
Tryandroid:layout_alignParentTop="true"
andandroid:layout_alignParentLeft="true"
for both elements.
– Ali Sheikhpour
Jun 5 '16 at 8:16
From the design guidelines: "Floating action buttons don’t contain app bar icons or status bar notifications. Don’t layer badges or other elements over a floating action button." google.com/design/spec/components/…
– Daniel Nugent
Jun 5 '16 at 8:14
From the design guidelines: "Floating action buttons don’t contain app bar icons or status bar notifications. Don’t layer badges or other elements over a floating action button." google.com/design/spec/components/…
– Daniel Nugent
Jun 5 '16 at 8:14
Try
android:layout_alignParentTop="true"
and android:layout_alignParentLeft="true"
for both elements.– Ali Sheikhpour
Jun 5 '16 at 8:16
Try
android:layout_alignParentTop="true"
and android:layout_alignParentLeft="true"
for both elements.– Ali Sheikhpour
Jun 5 '16 at 8:16
add a comment |
6 Answers
6
active
oldest
votes
As suggested by Daniel, you should not add badges to Floating Action Buttons. However, if you really have to do it, try adding this property to your TextView:
android:elevation="7dp"
add a comment |
I used the CounterFab library to achieve this.
It is as simple as adding it to your XML layout file instead of the regular FloatingActionButton
and calling counterFab.setCount(10);
(See usage example here).
It isn't working fine for Android 6.0 or lower versions.
– Weaboo
Jun 10 '18 at 7:41
add a comment |
One can simply use TextView
by giving custom style for floating.
<TextView
android:id="@+id/fabCounter"
style="@style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:text="10"
android:textColor="@android:color/black"
android:textSize="14sp" />
add a comment |
For this problem solution is android:elevation="7dp"
. But you are looking for something like this then use bellow code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/margin.2">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_cart"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/margin.2"
app:srcCompat="@drawable/ic_add_shopping_cart"
app:backgroundTint="@color/colorPrimaryDark" />
<TextView
android:id="@+id/text_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="7dp"
android:gravity="center"
android:textColor="@color/white"
android:layout_alignParentRight="true"
android:textSize="@dimen/text.size.small"
android:background="@drawable/bg_fab"
tools:text="10" />
</RelativeLayout>
</RelativeLayout>
add a comment |
Give it a Try :
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
app:layout_anchor="@+id/containerpager"
app:layout_anchorGravity="bottom|right">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:elevation="0dp"
android:visibility="visible"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_review_order" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="5"
android:textColor="@color/white"
android:textSize="22sp"
android:visibility="visible" />
</RelativeLayout>
add a comment |
try this changes:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
android:src="@android:color/transparent"
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"/>
</FrameLayout>
not working on RelativeLayout.
– Md Imran Choudhury
May 25 '17 at 9:21
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37639698%2fbadge-count-on-floating-action-button%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
As suggested by Daniel, you should not add badges to Floating Action Buttons. However, if you really have to do it, try adding this property to your TextView:
android:elevation="7dp"
add a comment |
As suggested by Daniel, you should not add badges to Floating Action Buttons. However, if you really have to do it, try adding this property to your TextView:
android:elevation="7dp"
add a comment |
As suggested by Daniel, you should not add badges to Floating Action Buttons. However, if you really have to do it, try adding this property to your TextView:
android:elevation="7dp"
As suggested by Daniel, you should not add badges to Floating Action Buttons. However, if you really have to do it, try adding this property to your TextView:
android:elevation="7dp"
edited Nov 23 '18 at 10:31
Rohit5k2
14.3k42551
14.3k42551
answered Aug 10 '16 at 13:30
LucaLuca
312
312
add a comment |
add a comment |
I used the CounterFab library to achieve this.
It is as simple as adding it to your XML layout file instead of the regular FloatingActionButton
and calling counterFab.setCount(10);
(See usage example here).
It isn't working fine for Android 6.0 or lower versions.
– Weaboo
Jun 10 '18 at 7:41
add a comment |
I used the CounterFab library to achieve this.
It is as simple as adding it to your XML layout file instead of the regular FloatingActionButton
and calling counterFab.setCount(10);
(See usage example here).
It isn't working fine for Android 6.0 or lower versions.
– Weaboo
Jun 10 '18 at 7:41
add a comment |
I used the CounterFab library to achieve this.
It is as simple as adding it to your XML layout file instead of the regular FloatingActionButton
and calling counterFab.setCount(10);
(See usage example here).
I used the CounterFab library to achieve this.
It is as simple as adding it to your XML layout file instead of the regular FloatingActionButton
and calling counterFab.setCount(10);
(See usage example here).
edited Apr 26 '17 at 15:19
answered Apr 15 '17 at 20:32
TomerTomer
2,1271721
2,1271721
It isn't working fine for Android 6.0 or lower versions.
– Weaboo
Jun 10 '18 at 7:41
add a comment |
It isn't working fine for Android 6.0 or lower versions.
– Weaboo
Jun 10 '18 at 7:41
It isn't working fine for Android 6.0 or lower versions.
– Weaboo
Jun 10 '18 at 7:41
It isn't working fine for Android 6.0 or lower versions.
– Weaboo
Jun 10 '18 at 7:41
add a comment |
One can simply use TextView
by giving custom style for floating.
<TextView
android:id="@+id/fabCounter"
style="@style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:text="10"
android:textColor="@android:color/black"
android:textSize="14sp" />
add a comment |
One can simply use TextView
by giving custom style for floating.
<TextView
android:id="@+id/fabCounter"
style="@style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:text="10"
android:textColor="@android:color/black"
android:textSize="14sp" />
add a comment |
One can simply use TextView
by giving custom style for floating.
<TextView
android:id="@+id/fabCounter"
style="@style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:text="10"
android:textColor="@android:color/black"
android:textSize="14sp" />
One can simply use TextView
by giving custom style for floating.
<TextView
android:id="@+id/fabCounter"
style="@style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:text="10"
android:textColor="@android:color/black"
android:textSize="14sp" />
answered Nov 18 '17 at 5:24
Aks4125Aks4125
2,76111233
2,76111233
add a comment |
add a comment |
For this problem solution is android:elevation="7dp"
. But you are looking for something like this then use bellow code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/margin.2">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_cart"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/margin.2"
app:srcCompat="@drawable/ic_add_shopping_cart"
app:backgroundTint="@color/colorPrimaryDark" />
<TextView
android:id="@+id/text_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="7dp"
android:gravity="center"
android:textColor="@color/white"
android:layout_alignParentRight="true"
android:textSize="@dimen/text.size.small"
android:background="@drawable/bg_fab"
tools:text="10" />
</RelativeLayout>
</RelativeLayout>
add a comment |
For this problem solution is android:elevation="7dp"
. But you are looking for something like this then use bellow code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/margin.2">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_cart"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/margin.2"
app:srcCompat="@drawable/ic_add_shopping_cart"
app:backgroundTint="@color/colorPrimaryDark" />
<TextView
android:id="@+id/text_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="7dp"
android:gravity="center"
android:textColor="@color/white"
android:layout_alignParentRight="true"
android:textSize="@dimen/text.size.small"
android:background="@drawable/bg_fab"
tools:text="10" />
</RelativeLayout>
</RelativeLayout>
add a comment |
For this problem solution is android:elevation="7dp"
. But you are looking for something like this then use bellow code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/margin.2">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_cart"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/margin.2"
app:srcCompat="@drawable/ic_add_shopping_cart"
app:backgroundTint="@color/colorPrimaryDark" />
<TextView
android:id="@+id/text_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="7dp"
android:gravity="center"
android:textColor="@color/white"
android:layout_alignParentRight="true"
android:textSize="@dimen/text.size.small"
android:background="@drawable/bg_fab"
tools:text="10" />
</RelativeLayout>
</RelativeLayout>
For this problem solution is android:elevation="7dp"
. But you are looking for something like this then use bellow code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/margin.2">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_cart"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/margin.2"
app:srcCompat="@drawable/ic_add_shopping_cart"
app:backgroundTint="@color/colorPrimaryDark" />
<TextView
android:id="@+id/text_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="7dp"
android:gravity="center"
android:textColor="@color/white"
android:layout_alignParentRight="true"
android:textSize="@dimen/text.size.small"
android:background="@drawable/bg_fab"
tools:text="10" />
</RelativeLayout>
</RelativeLayout>
answered Mar 12 '18 at 7:22
Md Imran ChoudhuryMd Imran Choudhury
3,00612337
3,00612337
add a comment |
add a comment |
Give it a Try :
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
app:layout_anchor="@+id/containerpager"
app:layout_anchorGravity="bottom|right">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:elevation="0dp"
android:visibility="visible"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_review_order" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="5"
android:textColor="@color/white"
android:textSize="22sp"
android:visibility="visible" />
</RelativeLayout>
add a comment |
Give it a Try :
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
app:layout_anchor="@+id/containerpager"
app:layout_anchorGravity="bottom|right">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:elevation="0dp"
android:visibility="visible"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_review_order" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="5"
android:textColor="@color/white"
android:textSize="22sp"
android:visibility="visible" />
</RelativeLayout>
add a comment |
Give it a Try :
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
app:layout_anchor="@+id/containerpager"
app:layout_anchorGravity="bottom|right">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:elevation="0dp"
android:visibility="visible"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_review_order" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="5"
android:textColor="@color/white"
android:textSize="22sp"
android:visibility="visible" />
</RelativeLayout>
Give it a Try :
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
app:layout_anchor="@+id/containerpager"
app:layout_anchorGravity="bottom|right">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:elevation="0dp"
android:visibility="visible"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_review_order" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="5"
android:textColor="@color/white"
android:textSize="22sp"
android:visibility="visible" />
</RelativeLayout>
answered Oct 28 '17 at 12:26
LMJ-ackLMJ-ack
111
111
add a comment |
add a comment |
try this changes:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
android:src="@android:color/transparent"
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"/>
</FrameLayout>
not working on RelativeLayout.
– Md Imran Choudhury
May 25 '17 at 9:21
add a comment |
try this changes:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
android:src="@android:color/transparent"
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"/>
</FrameLayout>
not working on RelativeLayout.
– Md Imran Choudhury
May 25 '17 at 9:21
add a comment |
try this changes:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
android:src="@android:color/transparent"
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"/>
</FrameLayout>
try this changes:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"
android:src="@android:color/transparent"
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"/>
</FrameLayout>
answered Jun 5 '16 at 8:23
mehrdad khosravimehrdad khosravi
2,14292131
2,14292131
not working on RelativeLayout.
– Md Imran Choudhury
May 25 '17 at 9:21
add a comment |
not working on RelativeLayout.
– Md Imran Choudhury
May 25 '17 at 9:21
not working on RelativeLayout.
– Md Imran Choudhury
May 25 '17 at 9:21
not working on RelativeLayout.
– Md Imran Choudhury
May 25 '17 at 9:21
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37639698%2fbadge-count-on-floating-action-button%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
From the design guidelines: "Floating action buttons don’t contain app bar icons or status bar notifications. Don’t layer badges or other elements over a floating action button." google.com/design/spec/components/…
– Daniel Nugent
Jun 5 '16 at 8:14
Try
android:layout_alignParentTop="true"
andandroid:layout_alignParentLeft="true"
for both elements.– Ali Sheikhpour
Jun 5 '16 at 8:16