I want to have rounded corners for each menu item in BottomNavigation menu. Sample menu image is attached. Is it possible?
Asked
Active
Viewed 179 times
3 Answers
1
Finally, I find a solution to my problem
Add to the bg_prog_round.xml file
<solid android:color="@color/edit_text_back" /> <stroke android:width="0dp" android:color="@color/edit_text_back" /> <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" />
Create another XML file and add this to it (bg_prog_orange_round.xml)
<solid android:color="@color/orange" /> <stroke android:width="2dp" android:color="@color/orange" /> <corners android:bottomLeftRadius="@dimen/_15sdp" android:bottomRightRadius="@dimen/_15sdp" android:topLeftRadius="@dimen/_15sdp" android:topRightRadius="@dimen/_15sdp" />
Create bottom_back_nav.xml
Add this to your BottomNavigationView ->
app:itemBackground="@drawable/bottom_nav_back"
also, add paddingStart, paddingEnd
to it
<com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_nav" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" app:itemIconTint="@drawable/bottom_navigation_colors" app:itemTextColor="@drawable/bottom_navigation_colors" app:itemBackground="@drawable/bottom_nav_back" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintStart_toStartOf="parent" app:labelVisibilityMode="unlabeled" android:paddingStart="@dimen/_45sdp" android:paddingEnd="@dimen/_45sdp" android:paddingTop="@dimen/_8sdp" android:paddingBottom="@dimen/_5sdp" app:menu="@menu/bottom_nav_menu" />

Mona Baharlou
- 1,401
- 1
- 13
- 26
0
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

Biscuit
- 4,840
- 4
- 26
- 54
-
Thanks for your reply. It is a great library, but I prefer not using the library. I found a solution for that. – Mona Baharlou Sep 30 '20 at 13:30
0
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>

Sarthak Dhami
- 330
- 1
- 5
- 14
-
I wanted to customize BottomNavigationView, not using RelativeLayout. Thanks anyway – Mona Baharlou Sep 30 '20 at 13:29