I want to have rounded corners for each menu item in BottomNavigation menu. Sample menu image is attached. Is it possible?
Rounded menu item in BottomNavigationMenu
214 views Asked by Mona Baharlou At
3
There are 3 answers
1
On
You can Add in your layout file
<RelativeLayout
android:id="@+id/rel_titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/_20dp"
android:layout_marginTop="265dp"
android:layout_marginRight="@dimen/_20dp"
android:gravity="center|right">
<!---->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="3dp"
android:background="@drawable/gradient_in_purchase"
android:paddingTop="@dimen/_10dp"
android:paddingBottom="@dimen/_10dp">
<ImageView
android:layout_marginRight="@dimen/_20dp"
android:layout_alignParentRight="true"
android:src="@drawable/ic_pro1"
android:layout_width="@dimen/_24dp"
android:layout_height="@dimen/_24dp"/>
</RelativeLayout>
</RelativeLayout>
Add gradient_in_purchase XML in your drawable folder and add below code
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/orange"
android:angle="0"/>
<corners
android:bottomLeftRadius="@dimen/_10dp"
android:bottomRightRadius="@dimen/_10dp"
android:topLeftRadius="@dimen/_10dp"
android:topRightRadius="@dimen/_10dp"/>
</shape>
1
On
I recommend you to use a library to do this kind of menu, I found this one https://github.com/gauravk95/bubble-navigation which can be helpful
Finally, I find a solution to my problem
Add to the bg_prog_round.xml file
Create another XML file and add this to it (bg_prog_orange_round.xml)
Create bottom_back_nav.xml
Add this to your BottomNavigationView ->
app:itemBackground="@drawable/bottom_nav_back"
also, add
paddingStart, paddingEnd
to itAnd the result is here