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>
Remove this app:layout_behavior="#string/appbar_scrolling_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">
<?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"
tools:context="com.example.kun.carkila.DetailActivity">
<EditText
android:id="#+id/etResDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/etPickup"
android:editable="false"
android:hint="Reservation Date" />
<EditText
android:id="#+id/etResTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/etResDate"
android:editable="false"
android:hint="Reservation Time" />
<EditText
android:id="#+id/etPickup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tvPoster"
android:layout_marginTop="22dp"
android:ems="10"
android:hint="Pickup Location"
android:inputType="textPersonName" />
<EditText
android:id="#+id/etReturnTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/etReturnDate"
android:editable="false"
android:hint="Return Time" />
<Button
android:id="#+id/btnRent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/etReturnTime"
android:layout_centerHorizontal="true"
android:text="Rent" />
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#android:drawable/star_big_on" />
<TextView
android:id="#+id/tvCarModel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ivImage"
android:layout_centerHorizontal="true"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvCarType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCarModel"
android:layout_alignStart="#+id/tvCarModel"
android:layout_below="#+id/tvCarModel"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvCapacity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvCarType"
android:layout_alignStart="#+id/tvCarType"
android:layout_below="#+id/tvCarType"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvFuelType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvCapacity"
android:layout_centerHorizontal="true"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvPoster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvPlateNumber"
android:layout_alignStart="#+id/tvPlateNumber"
android:layout_below="#+id/tvPlateNumber"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/tvPlateNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tvFuelType"
android:layout_alignStart="#+id/tvFuelType"
android:layout_below="#+id/tvFuelType"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/etReturnDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/etResTime"
android:editable="false"
android:hint="Return Date" />
</RelativeLayout>
</ScrollView>
check if this helps
Please do something like the XML code below or just simply add your EditText/TextView component in between NestedScrollView.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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/addtimesheetlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.kun.carkila.DetailActivity"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:id="#+id/scrollableview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!--Add your EditText here-->
</LinearLayout><!--Main layout ends-->
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
Related
Im trying to put a TextView below a multiline EditText and if the EditText starts to grow in height the TextView needs to stay below the EditText, right now if the EditText starts to grow it just covers the TextView below, they are inside a RelativeLayout. Here is the XML of the two objects:
<EditText
android:id="#+id/descripcion_actividad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/descripcion_actividad_label"
android:layout_alignBottom="#+id/descripcion_actividad_label"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_toEndOf="#+id/cantidad"
android:layout_toRightOf="#+id/cantidad"
android:ems="10"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/hora_inicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/descripcion_actividad"
android:layout_alignParentBottom="false"
android:layout_below="#+id/descripcion_actividad"
android:layout_alignStart="#+id/descripcion_actividad"
android:text="TextView" />
EDIT: Whole layout:
<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:id="#+id/activity_third_form_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="dbxprts.terminaltrak.PlanTrabajoActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ToolBarStyle" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/my_toolbar"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/activity_third_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="dbxprts.terminaltrak.PlanTrabajoActivity">
<Spinner
android:id="#+id/liberado_rechazado"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tipo_fase"
android:layout_alignStart="#+id/tipo_fase"
android:layout_below="#+id/tipo_fase"
android:layout_marginTop="5dp"
android:entries="#array/array_liberado_rechazado"
android:visibility="gone" />
<Spinner
android:id="#+id/id_cliente"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/id_cliente_label"
android:layout_marginLeft="35dp"
android:layout_toEndOf="#+id/id_realizo_label"
android:layout_toRightOf="#+id/id_realizo_label" />
<TextView
android:id="#+id/hora_inicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/descripcion_actividad"
android:layout_alignParentBottom="false"
android:layout_alignStart="#+id/descripcion_actividad"
android:layout_below="#+id/descripcion_actividad"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="#+id/descripcion_actividad_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/id_cliente_label"
android:layout_marginTop="35dp"
android:text="Descripción Actividad:" />
<TextView
android:id="#+id/id_cliente_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/id_operacion_label"
android:layout_marginTop="35dp"
android:text="ID Cliente:" />
<Spinner
android:id="#+id/id_operacion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/id_operacion_label"
android:layout_marginLeft="25dp"
android:layout_toEndOf="#+id/id_operacion_label"
android:layout_toRightOf="#+id/id_operacion_label" />
<Spinner
android:id="#+id/id_supervisor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/id_supervisor_label"
android:layout_marginLeft="25dp"
android:layout_toEndOf="#+id/id_supervisor_label"
android:layout_toRightOf="#+id/id_supervisor_label" />
<TextView
android:id="#+id/id_operacion_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/cantidad_label"
android:layout_marginTop="35dp"
android:text="ID Operación:" />
<EditText
android:id="#+id/cantidad"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/cantidad_label"
android:layout_alignBottom="#+id/cantidad_label"
android:layout_toEndOf="#+id/id_supervisor_label"
android:layout_toRightOf="#+id/id_supervisor_label"
android:ems="10"
android:inputType="number" />
<TextView
android:id="#+id/cantidad_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/id_supervisor_label"
android:layout_centerVertical="true"
android:layout_marginTop="35dp"
android:text="Cantidad:" />
<TextView
android:id="#+id/id_programo_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tipo_fase_label"
android:layout_marginTop="35dp"
android:text="ID Programó:"
android:textSize="15sp" />
<Spinner
android:id="#+id/tipo_fase"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/tipo_fase_label"
android:layout_marginLeft="25dp"
android:layout_toEndOf="#+id/id_plan_label"
android:layout_toRightOf="#+id/id_plan_label"
android:dropDownWidth="match_parent"
android:minWidth="100dip" />
<TextView
android:id="#+id/id_supervisor_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/id_realizo_label"
android:layout_marginTop="35dp"
android:text="ID Supervisor:" />
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/id_realizo_label"
android:layout_alignLeft="#+id/tipo_fase"
android:layout_alignStart="#+id/tipo_fase"
android:layout_marginLeft="25dp" />
<Button
android:id="#+id/confirmar_cambios"
android:layout_width="120dp"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:layout_below="#+id/descarga_cronometro"
android:layout_centerHorizontal="true"
android:elevation="0dp"
android:text="Registrar Fase"
android:textAllCaps="false"
android:visibility="gone" />
<TextView
android:id="#+id/hora_inicio_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/hora_inicio"
android:text="Hora Inicio:" />
<Spinner
android:id="#+id/via"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/id_programo_label"
android:layout_marginLeft="25dp"
android:layout_toEndOf="#+id/id_programo_label"
android:layout_toRightOf="#+id/id_programo_label" />
<TextView
android:id="#+id/tipo_fase_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/id_plan_label"
android:layout_marginTop="35dp"
android:layout_toLeftOf="#+id/tipo_fase"
android:layout_toStartOf="#+id/tipo_fase"
android:text="Tipo Fase:"
android:textSize="15sp" />
<TextView
android:id="#+id/id_plan_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="ID Plan Label:"
android:textSize="15sp" />
<EditText
android:id="#+id/descripcion_actividad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/descripcion_actividad_label"
android:layout_alignBottom="#+id/descripcion_actividad_label"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_toEndOf="#+id/cantidad"
android:layout_toRightOf="#+id/cantidad"
android:ems="10"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/id_realizo_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/id_programo_label"
android:layout_marginTop="35dp"
android:text="ID Realizó:" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Place the EditText and Textview inside a LinearLayout with orientation as vertical
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rootLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/descripcion_actividad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
--------------------------
--------------------------
android:inputType="textMultiLine" />
<TextView
android:id="#+id/hora_inicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
--------------------------
--------------------------
android:text="TextView" />
</LinearLayout>
Use a Linearlayout instead .
<LinearLayout
android:layout_width="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_height="wrap_content">
<EditText
android:id="#+id/descripcion_actividad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/hora_inicio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
OR With Relative Layout use
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="#+id/descripcion_actividad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:inputType="textMultiLine" />
<TextView
android:id="#+id/hora_inicio"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
android:layout_below="#+id/descripcion_actividad"
android:text="TextView" />
</RelativeLayout>
I am trying to create a scrollable list with ratingbars and textviews.
However I am unable to get them to align correctly. I would like even spacing between all textviews and rating bars..
I have tried to use the layout_below but this does not produce what I would like, I have also tried dragging, but this also does not create the wanted effect.
Any help would be appreciated :)
<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:background="#color/colorPrimaryDark"
tools:context="uk.co.neverendingsport.neverendingsport.LoginActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:id="#+id/button" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Sports"
android:textSize="30sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/textView4"
android:layout_alignParentStart="true">
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Football"
android:textSize="30sp"
android:layout_above="#+id/cyclingRatingBar"
android:layout_alignParentStart="true" />
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cycling"
android:textSize="30sp"
android:layout_above="#+id/badmintonTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/footballRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Badminton"
android:textSize="30sp"
android:layout_below="#+id/cyclingRatingBar"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/runningTextView"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Running"
android:textSize="30sp"
android:layout_below="#+id/badmintonTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/badmintonRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Swimming"
android:textSize="30sp"
android:layout_below="#+id/runningTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/runningRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Golf"
android:textSize="30sp"
android:layout_below="#+id/swimmingTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/swimmingRatingBar"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
Image of current layout
Here is the answer that works fine for me
<?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">
<TextView
android:id="#+id/textView2"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Select Sports" />
<TextView
android:id="#+id/textView6"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/ratingBar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="17dp"
android:layout_toLeftOf="#+id/ratingBar"
android:layout_toStartOf="#+id/ratingBar"
android:text="Football" />
<RatingBar
android:id="#+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView2" />
<RatingBar
android:id="#+id/ratingBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/ratingBar" />
<RatingBar
android:id="#+id/ratingBar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/ratingBar2"
android:layout_alignStart="#+id/ratingBar2"
android:layout_below="#+id/ratingBar2" />
<RatingBar
android:id="#+id/ratingBar4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/ratingBar3"
android:layout_alignStart="#+id/ratingBar3"
android:layout_below="#+id/ratingBar3" />
<TextView
android:id="#+id/textView7"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/ratingBar3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="17dp"
android:layout_toLeftOf="#+id/textView2"
android:text="Cycling" />
<TextView
android:id="#+id/textView8"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/ratingBar4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="14dp"
android:layout_toLeftOf="#+id/ratingBar3"
android:text="Badminton" />
<TextView
android:id="#+id/textView9"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/ratingBar4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="16dp"
android:layout_toLeftOf="#+id/ratingBar4"
android:text="Running" />
</RelativeLayout>]
final output
First of all you need to add rating bar to parent layout and later textview to the parent layout
Try this
<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:background="#color/colorPrimaryDark"
tools:context="uk.co.neverendingsport.neverendingsport.LoginActivity">
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:text="Continue" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Select Sports"
android:textSize="30sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView4">
<RelativeLayout
android:id="#+id/relativeFootball"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Football"
android:textSize="30sp" />
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeCycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeFootball">
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Cycling"
android:textSize="30sp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeBadminton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeCycle">
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Badminton"
android:textSize="30sp" />
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeRunning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeBadminton">
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Running"
android:textSize="30sp" />
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeSwimming"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeRunning">
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:text="Swimming"
android:textSize="30sp" />
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeGolf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeSwimming">
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Golf"
android:textSize="30sp" />
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:id="#+id/button" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Sports"
android:textSize="28sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Football"
android:textSize="28sp"
android:layout_weight="1"
android:layout_above="#+id/cyclingRatingBar"
/>
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cycling"
android:textSize="28sp"
android:layout_weight="1"
android:layout_above="#+id/badmintonTextView"
android:layout_marginBottom="10dp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/footballRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Badminton"
android:textSize="28sp"
android:layout_below="#+id/cyclingRatingBar"
android:layout_weight="1"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/runningTextView"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Running"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/badmintonTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/badmintonRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Swimming"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/runningTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/runningRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Golf"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/swimmingTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/swimmingRatingBar"
>
</RatingBar>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Hi am try to add scroll to my activity.
My activity has two files
1)activity_temple_details
2)content_temple_details
When i try to scroll. The contents are visible on top of the app bar.
like this
I want the contents to go behind the appbar or disapper while scrolling
here is my code
activity_temple_details
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_temple__details" />
</android.support.design.widget.CoordinatorLayout>
content_temple_details
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:layout_centerInParent="true"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details"
tools:showIn="#layout/activity_temple__details">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:id="#+id/IV_temple_logo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_movie"
android:background="#drawable/image_view_style"
android:layout_marginRight="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Temple Name"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_title"
android:layout_below="#+id/textView"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Address"
android:id="#+id/textView3"
android:layout_below="#+id/TV_title"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_address"
android:layout_below="#+id/textView3"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Description"
android:id="#+id/textView5"
android:layout_below="#+id/IV_temple_logo"
android:layout_alignRight="#+id/IV_temple_logo"
android:layout_alignEnd="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:textSize="14dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_Description"
android:layout_below="#+id/textView5"
android:layout_alignRight="#+id/TV_title"
android:layout_alignEnd="#+id/TV_title"
android:background="#drawable/textview_style"
android:textSize="14dp"
android:layout_marginTop="8dp"
android:scrollbars = "vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Directions"
android:id="#+id/button"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_marginTop="70dp"
android:layout_below="#+id/TV_Description"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Again"
android:id="#+id/button2"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_alignTop="#+id/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suggest an Edit"
android:id="#+id/button3"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_below="#+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="15dp" />
</RelativeLayout>
</ScrollView>
can some one help me to fix this. tnx.
Try adding following line in scrollview
android:layout_marginTop="?attr/actionBarSize"
I guess it will help, It solved my problem.
layout file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="?attr/actionBarSize"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:layout_centerInParent="true"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details"
tools:showIn="#layout/activity_temple__details">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:id="#+id/IV_temple_logo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_movie"
android:background="#drawable/image_view_style"
android:layout_marginRight="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Temple Name"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_title"
android:layout_below="#+id/textView"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Address"
android:id="#+id/textView3"
android:layout_below="#+id/TV_title"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_address"
android:layout_below="#+id/textView3"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Description"
android:id="#+id/textView5"
android:layout_below="#+id/IV_temple_logo"
android:layout_alignRight="#+id/IV_temple_logo"
android:layout_alignEnd="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:textSize="14dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_Description"
android:layout_below="#+id/textView5"
android:layout_alignRight="#+id/TV_title"
android:layout_alignEnd="#+id/TV_title"
android:background="#drawable/textview_style"
android:textSize="14dp"
android:layout_marginTop="8dp"
android:scrollbars = "vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Directions"
android:id="#+id/button"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_marginTop="70dp"
android:layout_below="#+id/TV_Description"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Again"
android:id="#+id/button2"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_alignTop="#+id/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suggest an Edit"
android:id="#+id/button3"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_below="#+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="15dp" />
</RelativeLayout>
</ScrollView>
Within the CoordinatorLayout you have to use NestedScrollView but not ScrollView,
here is your solution
content_temple_details.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:layout_centerInParent="true"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details"
tools:showIn="#layout/activity_temple__details">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:id="#+id/IV_temple_logo"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/ic_action_movie"
android:background="#drawable/image_view_style"
android:layout_marginRight="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Temple Name"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_title"
android:layout_below="#+id/textView"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Address"
android:id="#+id/textView3"
android:layout_below="#+id/TV_title"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:layout_marginLeft="8dp"
android:textSize="14dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_address"
android:layout_below="#+id/textView3"
android:layout_toRightOf="#+id/IV_temple_logo"
android:layout_toEndOf="#+id/IV_temple_logo"
android:textSize="14dp"
android:layout_marginLeft="8dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Description"
android:id="#+id/textView5"
android:layout_below="#+id/IV_temple_logo"
android:layout_alignRight="#+id/IV_temple_logo"
android:layout_alignEnd="#+id/IV_temple_logo"
android:layout_marginTop="10dp"
android:textSize="14dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/TV_Description"
android:layout_below="#+id/textView5"
android:layout_alignRight="#+id/TV_title"
android:layout_alignEnd="#+id/TV_title"
android:background="#drawable/textview_style"
android:textSize="14dp"
android:layout_marginTop="8dp"
android:scrollbars = "vertical"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Directions"
android:id="#+id/button"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_marginTop="70dp"
android:layout_below="#+id/TV_Description"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Again"
android:id="#+id/button2"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_alignTop="#+id/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suggest an Edit"
android:id="#+id/button3"
android:background="#drawable/button_selector"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="18dp"
android:layout_below="#+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="15dp" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
/*Change it according to your requirement **/
<RelativeLayout
android:id="#+id/relative_activity_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/mainBackGroundColor"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="#+id/linearlayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="#+id/app_bar_id"
layout="#layout/app_bar"></include>
<include
android:id="#+id/yourlayout_id"
layout="#layout/yourLayout"></include>
</LinearLayout>
</RelativeLayout>
Please set layout behaviour inside your scrollview
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
I have a floating action button over a listview, but I can't click on the button when the list fills up so that the button and the list overlap. In that situation only the list item is clickable. How do I rectify this issue? Thanks in advance. My xml code is below.
<?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="wrap_content">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="5dp">
<RelativeLayout
android:id="#+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/frameLayout"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
android:background="#000000"
android:orientation="vertical"
android:padding="1.5dp"
android:weightSum="1">
<TextView
android:id="#+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#660033"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
<RelativeLayout
android:id="#+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="29dp"
android:background="#android:color/darker_gray"
android:padding="2dp">
<TextView
android:id="#+id/txtLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispLoc"
android:layout_gravity="left|top"
android:text="[Location]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispDesc"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="1dp"
android:text="[Description]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/dispLoc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="#string/loc"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/dispDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtLocation"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="17dp"
android:text="#string/desc"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/dispContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtDesc"
android:layout_marginTop="25dp"
android:text="#string/contact"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/txtContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/dispContact"
android:layout_toEndOf="#+id/dispLoc"
android:autoLink="email"
android:text="[ContactInfo]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/From"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispContact"
android:layout_marginTop="16dp"
android:text="#string/from"
android:textColor="#android:color/primary_text_light" />
<TextView
android:id="#+id/txtStartDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/From"
android:layout_marginLeft="10dp"
android:layout_toEndOf="#+id/From"
android:text="[Start Date]"
android:textColor="#android:color/secondary_text_light" />
<TextView
android:id="#+id/To"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtStartDate"
android:text="#string/to"
android:textColor="#android:color/primary_text_light" />
<TextView
android:id="#+id/txtEndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/txtStartDate"
android:layout_alignTop="#+id/To"
android:text="[End Date]"
android:textColor="#android:color/secondary_text_light" />
<Button
android:id="#+id/attend_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:text="Attend" />
<Button
android:id="#+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/txtContact"
android:text="Cancel" />
</RelativeLayout>
<TextView
android:id="#+id/txtType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtTitle"
android:layout_alignEnd="#+id/txtTitle"
android:text="Type"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/peopleAttending"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/card_view"
android:background="#660033"
android:text="#string/people_attending"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
<org.lucasr.twowayview.TwoWayView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/lvItems"
style="#style/TwoWayView"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_below="#+id/peopleAttending"
android:drawSelectorOnTop="false"
tools:context=".DetailedEventActivity" />
<com.software.shell.fab.ActionButton xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="#+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="#dimen/fab_margin"
android:layout_marginEnd="#dimen/fab_margin"
fab:button_color="#color/fab_material_red_500"
fab:button_colorPressed="#color/fab_material_red_900"
fab:hide_animation="#anim/fab_roll_to_down"
fab:image="#drawable/fab_plus_icon"
fab:image_size="24dp"
fab:shadow_color="#757575"
fab:shadow_radius="1.0dp"
fab:shadow_xOffset="0.5dp"
fab:shadow_yOffset="1.0dp"
fab:show_animation="#anim/fab_roll_from_down"
fab:stroke_color="#color/fab_material_blue_grey_500"
fab:stroke_width="1.0dp"
fab:type="DEFAULT"
android:clickable="true"/>
<ListView
android:id="#+id/commentsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/lvItems"
android:layout_marginTop="0dp"
/>
Move your FAB to the bottom of the XML (below the ListView).
I have kept my RelativeLayout inside a ScrollView but still it is not becoming scrollable and also i am not getting extra space to drag and drop more view in my layout. plzz help..
I am new to android any answers will be a great help for me....Thanks in Advance.......
<?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"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b8fce8"
android:gravity="bottom" >
<TextView
android:id="#+id/txtDocProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Doctor Profile"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/lblDocName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtDocProfile"
android:layout_marginTop="14dp"
android:text="Name :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtDocName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/lblDocName"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/tetSpecilazation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/lblDocSpeciality"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/lblDocQualification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tetSpecilazation"
android:layout_marginTop="22dp"
android:text="Qualification :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtDocQualification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/lblDocQualification"
android:layout_below="#+id/lblDocQualification"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/lblDocSpeciality"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtDocName"
android:layout_marginTop="16dp"
android:text="Specilization :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/lblAddress1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Address 1 :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtDocQualification"
android:layout_alignParentRight="true"
android:layout_below="#+id/lblAddress1"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="4"
android:scrollHorizontally="false"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/lblContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView1"
android:layout_marginTop="27dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/lblMobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView1"
android:layout_alignRight="#+id/txtDocQualification"
android:layout_below="#+id/lblContact"
android:text="Mobile No :"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtDocMobNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/lblMobile"
android:layout_alignBottom="#+id/lblMobile"
android:layout_toRightOf="#+id/lblMobile"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/btnCallMob"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/txtDocMobNo"
android:layout_marginRight="16dp"
android:text="Call" />
<TextView
android:id="#+id/lblDocPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/lblMobile"
android:layout_alignParentBottom="true"
android:text="Landline "
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtDocPhoneNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/lblMobile"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/btnCallPhone"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/btnCallMob"
android:layout_alignParentBottom="true"
android:text="Call" />
</RelativeLayout>
</ScrollView>
<?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"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!--put here your button and all other-->
</LinearLayout>
</ScrollView>
</RelativeLayout>
Actually it not works because of this
android:layout_alignParentBottom="true"
So the last component laid on bottom of Relative Layout and not stretching anywhere
If you want to stretch your Relative Layout try to add your component stack vertically each other with
android:layout_below="#+id/yourComponentBefore"
i give it example
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#b8fce8"
android:gravity="bottom" >
<TextView
android:id="#+id/ComponentOne"
android:layout_width="match_parent"
android:layout_height="450dp"
android:background="#CFCFCF" />
<TextView
android:id="#+id/ComponentTwo"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_below="#+id/ComponentOne"
android:background="#FFFFFF" />
<TextView
android:id="#+id/ComponentThree"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_below="#+id/ComponentTwo"
android:background="#000000" />
</RelativeLayout>