Reputation: 231
I have problem with BottomNavigationViewEx: menu overlaps the bottom part of my activity. I wanted to fix that by adding bottom margin to my content (in that case in ScrollView), but I don't know what is the actual height of BottomNavigationViewEx menu, and even if I would know it, I'm not sure if it is the same (in dp) in all devices. Below my code:
<android.support.constraint.ConstraintLayout
...
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
...
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--
...
content of my activity
...
-->
</ScrollView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
...
app:menu="@drawable/main_menu"/>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
How to make the content of my scroll view shorter, to avoid overlaping with bottom menu?
Upvotes: 1
Views: 2322
Reputation: 557
I got this to work by adding:
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="<id of bottom nav view>"
to the FrameLayout that holds my content. Here is the entire layout file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/navigation"/>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>
Upvotes: 2
Reputation: 4445
You can do one thing , set the fixed height for bottom menu and set margin bottom to Scrollview, then bottommenu will not overlap your layout.
<android.support.constraint.ConstraintLayout
...
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_marginBottom="60dp"
...
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--
...
content of my activity
...
-->
</ScrollView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
...
app:menu="@drawable/main_menu"/>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
Upvotes: 0
Reputation: 137
Why don't you set a value for ScrollView layout_height = "wrap_content". Currently you are setting it to match parent/fill_parent(deprecated) and that is stretching it's content to the height of your layout, in this case ConstraintLayout. If this doesn't help try replacing ConstraintLayout with vertically oriented LinearLayout
Upvotes: 0