I was trying to make a lower navigation bar and because the views where a lot I needed to use a scroll view but the problem is that the last element in the scroll view doesn’t appear because of the navigation bar.
so what can I do to make last element appear??
my xml code is :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:background="#E6E6E6"
android:layout_height="match_parent"
tools:context=".mainPage">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:fontFamily="@font/lato_bold"
android:text="Servings"
android:textColor="@color/purple_700"
android:textSize="20sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="number"
android:id="@+id/servings"
android:hint="Servings that you will eat"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:fontFamily="@font/lato_bold"
android:text="grams per serving"
android:textColor="@color/purple_700"
android:textSize="20sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="number"
android:id="@+id/grams"
android:hint="grams per serving"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:fontFamily="@font/lato_bold"
android:text="calories for each serving"
android:textColor="@color/purple_700"
android:textSize="20sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="number"
android:id="@+id/calories"
android:hint="calories for each serving"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:fontFamily="@font/lato_bold"
android:text="meal name"
android:textColor="@color/purple_700"
android:textSize="20sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:inputType="text"
android:id="@+id/name"
android:hint="type the meal name"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/add"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/lato_bold"
android:text="Add"
android:textSize="14sp" />
<Button
android:id="@+id/dont"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/lato_bold"
android:text="Don’t know how many calories are in this meal ?"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/main_food"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/lato_bold"
android:text="What have you eaten today"
android:textSize="14sp" />
<Button
android:id="@+id/adding_food"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/lato_bold"
android:text="Food Adding"
android:textSize="14sp" />
<Button
android:id="@+id/profile_food"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/lato_bold"
android:text="Profile"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
so how can I make the last element in the scroll view because the navigaion bar is blocking it (it’s in the front of it so the last element doesn’t show.
This is an image of it and as you can see the navigation bar is in the front of the last element so it doesn’t show because of that
2
Answers
Add
android:paddingBottom = "Xdp"
, whereX
is something bigger than your bottom bar, to the last LinearLayout.Example:
android:paddingBottom = "30dp"
Add
id
to Bottom navigation barLinearLayout
Add
android:layout_above="@+id/yourbottomlayoutid"
,android:layout_height="match_parent"
andandroid:fillViewport="true"
to yourScrollView
.For reference check below code: