I have a bottomsheet which includes a layout. And that layout has relative layout. Which has default margins. Even i set margins to 0dp it's not working.
bottom_sheet_back.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/blue_back"/>
</RelativeLayout>
code inside activity_main.xml
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:elevation="10dp"
android:padding="0dp">
<com.google.android.material.bottomappbar.BottomAppBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<include layout="@layout/bottom_sheet_back"/>
</com.google.android.material.bottomappbar.BottomAppBar>
This is giving me result like this.
where as bottom_sheet_back.xml has full width.
As you can see in 1st image i want to remove that margins.
Solution Tried
Above solutions are not much help in my scenario. I tried one more solution and it was to edit dimens.xml
but, I can't seem to find it anywhere. I use android studio 4.1.3 which has constraintLayout by default. So, dimens.xml
is not generated by project. But, if it is not generated by project then how did RelativeLayout
got margins?
Any help will be appreciated.
I have managed to get around your problem, i think theres aproblem with BottomAppbar, but if u change to BottomNavigationView it works very well with no problem, it removes the default margin
here is the code for the Bottom navigation i used
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<include layout="@layout/bottom_sheet_back"/>
</com.google.android.material.bottomnavigation.BottomNavigationView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
thanks