Reputation: 835
Regarding ConstraintLayout Notification Badge
I have used ConstraintLayout for notification as shown below.
here i used ImageButton and textview
out put:
here i used Button and textview
output :
insted of imageview is used button then it look like this. can any help me to solve this in constraintLayout.
when i tryed with button it displaying like this .
one more new thing i got to know if you are using FrameLayout or RelativeLayout display badge is working fine for both Button , ImageView or ImageButtom.
But on long-press or click of Button Notification badge is going back , in Imageview and imagebutton it working fine.
Upvotes: 10
Views: 2375
Reputation: 835
Final i got the solution for the above question
1 : for Button android:elevation will not effect beacuse internal it has elevation.
instead of elevation use android:stateListAnimator="@null"
2 : for other then button elevation will work
Upvotes: 0
Reputation: 7281
Use this style="?android:attr/borderlessButtonStyle"
in the Button xml
<Button
style="?android:attr/borderlessButtonStyle"
android:background="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Upvotes: 2
Reputation: 7936
This happens, because Button has its own elevation.
Higher elevation, gets views to the front.
Try adding higher elevation to your Badge like below.
android:elevation="10dp"
And, you don't want to scale your Image, you must use ImageView or ImageButton.
Upvotes: 3