J. Shmoe J. Shmoe - 3 months ago 31
Android Question

Scrollview on Relative layout overlapping on toolbar

My scrollview on my .xml is working but it's overlapping on the toolbar I can't press back on the hierarchy anymore and also I just updated my android studio to 2.2 Beta idk if this is the problem.

Here it is.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<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:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.kun.carkila.DetailActivity"
tools:showIn="@layout/activity_detail">


<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/etResDate"
android:editable="false"
android:hint="Reservation Date"
android:layout_below="@+id/etPickup"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/etResTime"
android:editable="false"
android:hint="Reservation Time"
android:layout_below="@+id/etResDate"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/etPickup"
android:hint="Pickup Location"
android:layout_below="@+id/tvPoster"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="22dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/etReturnTime"
android:editable="false"
android:hint="Return Time"
android:layout_below="@+id/etReturnDate"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rent"
android:id="@+id/btnRent"
android:layout_below="@+id/etReturnTime"
android:layout_centerHorizontal="true" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ivImage"
android:src="@android:drawable/star_big_on"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/tvCarModel"
android:layout_below="@+id/ivImage"
android:layout_centerHorizontal="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/tvCarType"
android:layout_below="@+id/tvCarModel"
android:layout_alignLeft="@+id/tvCarModel"
android:layout_alignStart="@+id/tvCarModel" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/tvCapacity"
android:layout_below="@+id/tvCarType"
android:layout_alignLeft="@+id/tvCarType"
android:layout_alignStart="@+id/tvCarType" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/tvFuelType"
android:layout_below="@+id/tvCapacity"
android:layout_centerHorizontal="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/tvPoster"
android:layout_below="@+id/tvPlateNumber"
android:layout_alignLeft="@+id/tvPlateNumber"
android:layout_alignStart="@+id/tvPlateNumber" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/tvPlateNumber"
android:layout_below="@+id/tvFuelType"
android:layout_alignLeft="@+id/tvFuelType"
android:layout_alignStart="@+id/tvFuelType" />

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/etReturnDate"
android:editable="false"
android:hint="Return Date"
android:layout_below="@+id/etResTime"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

</RelativeLayout>




screenshot of my overlapping scrollview

Answer

Remove this app:layout_behavior‌​="@string/appbar_scro‌​lling_view_behavior" from Relative Layout.

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

  <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:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.kun.carkila.DetailActivity"
    tools:showIn="@layout/activity_detail">