I have a problem with my XML layout, something that I thought wouldn't give me many problems. I have a layout below in a scroll view, but the bottom of the layout is being cut off, I can't see anything past the second list view. From looking around, I can't seem to see anything wrong with the xml itself and I can't see what I am doing wrong.
I have tried the suggestion to the problem, that is adding a weight to each of the different elements but this still hasnt solved the problem.
I have also added the main activity in which the fragment is placed incase that might help solve the problem
Fragment XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinatorLayout">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Recipe Title"/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/ingredientsHeading"
android:layout_below="@+id/text_input_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:text="Ingredients"
android:textStyle="bold|italic"
android:layout_weight="1" />
<ListView
android:id="@+id/ingredientsList"
android:layout_below="@+id/ingredientsHeading"
android:layout_above="@+id/directionsHeading"
android:layout_width="wrap_content"
android:layout_height="195dp"
android:layout_weight="1"></ListView>
<Button style="@style/Button"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Add Ingredient"
android:id="@+id/addIngredient"
android:layout_below="@+id/ingredientsList"
android:enabled="true"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
<TextView
android:id="@+id/directionsHeading"
android:layout_below="@+id/addIngredient"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:text="Directions"
android:textStyle="bold|italic"
android:layout_weight="1" />
<ListView
android:id="@+id/directionsList"
android:layout_below="@+id/directionsHeading"
android:layout_width="wrap_content"
android:layout_height="195dp"
android:layout_weight="1"></ListView>
<Button style="@style/Button"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Add Direction"
android:id="@+id/addDirection"
android:layout_below="@+id/ingredientsList"
android:enabled="true"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/filterButton"
app:backgroundTint="@color/floatingButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:clickable="true"
android:src="@drawable/ic_filter"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="63dp"
android:layout_marginRight="16dp" />
</android.support.design.widget.CoordinatorLayout>
Main XML
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout2">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<FrameLayout
android:id="@+id/container_body"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</android.support.design.widget.CoordinatorLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:name="com.example.rory.pocketchef.Fragments.FragmentDrawer"
android:layout_width="@dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
I solved the issue. As the scroll view was being displayed the bottom was being cut off by the bottom action bar on the actual phone. So to solve this I added padding to the bottom of the scrollview in order to push it back up above the action bar.
The new layout it as follows
Updated working XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinatorLayout">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="vertical"
android:paddingBottom="?android:attr/actionBarSize"> <<<-------added this line
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Recipe Title"/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/ingredientsHeading"
android:layout_below="@+id/text_input_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:text="Ingredients"
android:textStyle="bold|italic"
android:layout_weight="1" />
<ListView
android:id="@+id/ingredientsList"
android:layout_below="@+id/ingredientsHeading"
android:layout_above="@+id/directionsHeading"
android:layout_width="wrap_content"
android:layout_height="195dp"
android:layout_weight="1"></ListView>
<Button style="@style/Button"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Add Ingredient"
android:id="@+id/addIngredient"
android:layout_below="@+id/ingredientsList"
android:enabled="true"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
<TextView
android:id="@+id/directionsHeading"
android:layout_below="@+id/addIngredient"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:text="Directions"
android:textStyle="bold|italic"
android:layout_weight="1" />
<ListView
android:id="@+id/directionsList"
android:layout_below="@+id/directionsHeading"
android:layout_width="wrap_content"
android:layout_height="195dp"
android:layout_weight="1"></ListView>
<Button style="@style/Button"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Add Direction"
android:id="@+id/addDirection"
android:layout_below="@+id/ingredientsList"
android:enabled="true"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="@+id/addDirection">
<Button style="@style/Button"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Add Direction"
android:id="@+id/showOptionsDialog"
android:enabled="true"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
<Button style="@style/Button"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Add Direction"
android:id="@+id/saveRecipe"
android:enabled="true"
android:layout_gravity="center_horizontal"
android:layout_toRightOf="@+id/showOptionsDialog"
android:layout_weight="1" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/filterButton"
app:backgroundTint="@color/floatingButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:clickable="true"
android:src="@drawable/ic_filter"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="63dp"
android:layout_marginRight="16dp" />
</android.support.design.widget.CoordinatorLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With