<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.code.zero.drivermechanicsapp.AccidentAlertFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:text="Report Road Incident"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
tools:text="Report Road Incident"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="16dp"
android:textSize="18sp"
android:textStyle="bold"/>
<TextView
android:text="Concern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
tools:text="Concern"
app:layout_constraintTop_toTopOf="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
android:layout_marginStart="120dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="120dp"
android:layout_marginTop="64dp"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<TextView
android:text="Where"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView5"
tools:text="Where"
app:layout_constraintTop_toTopOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/textView3" />
<TextView
android:text="Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6"
tools:text="Description"
app:layout_constraintLeft_toLeftOf="#+id/textView5"
app:layout_constraintTop_toTopOf="#+id/editText4"
android:minLines="3"
android:maxLines="5"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText4"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText2"
android:maxLines="5"
android:minLines="3" />
<Button
android:text="Send S.O.S."
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:text="Phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView21"
app:layout_constraintLeft_toLeftOf="#+id/textView6"
app:layout_constraintTop_toTopOf="#+id/editText3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText3"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText4"
app:layout_constraintLeft_toLeftOf="#+id/editText4" />
because as i type it will block the screen. i cant even see what im typing.
and i'm really new in this android development. i don't know what to do.
can you please help me with this>?
because as i type it will block the screen. i cant even see what im typing.
and i'm really new in this android development. i don't know what to do.
can you please help me with this>?
put your views in scrollView like below:
<FrameLayout 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"
>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="Report Road Incident"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
tools:text="Report Road Incident"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="16dp"
android:textSize="18sp"
android:textStyle="bold"/>
<TextView
android:text="Concern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
tools:text="Concern"
app:layout_constraintTop_toTopOf="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
android:layout_marginStart="120dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="120dp"
android:layout_marginTop="64dp"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<TextView
android:text="Where"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView5"
tools:text="Where"
app:layout_constraintTop_toTopOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/textView3" />
<TextView
android:text="Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6"
tools:text="Description"
app:layout_constraintLeft_toLeftOf="#+id/textView5"
app:layout_constraintTop_toTopOf="#+id/editText4"
android:minLines="3"
android:maxLines="5"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText4"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText2"
android:maxLines="5"
android:minLines="3" />
<Button
android:text="Send S.O.S."
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:text="Phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView21"
app:layout_constraintLeft_toLeftOf="#+id/textView6"
app:layout_constraintTop_toTopOf="#+id/editText3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText3"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText4"
app:layout_constraintLeft_toLeftOf="#+id/editText4" />
</LinearLayout>
</ScrollView>
</FrameLayout>
To scroll your screen you simply need to do put a ScrollView inside your layout, like that:
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.code.zero.drivermechanicsapp.AccidentAlertFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Report Road Incident"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
tools:text="Report Road Incident"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="16dp"
android:textSize="18sp"
android:textStyle="bold"/>
<TextView
android:text="Concern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
tools:text="Concern"
app:layout_constraintTop_toTopOf="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
android:layout_marginStart="120dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="120dp"
android:layout_marginTop="64dp"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<TextView
android:text="Where"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView5"
tools:text="Where"
app:layout_constraintTop_toTopOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/textView3" />
<TextView
android:text="Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6"
tools:text="Description"
app:layout_constraintLeft_toLeftOf="#+id/textView5"
app:layout_constraintTop_toTopOf="#+id/editText4"
android:minLines="3"
android:maxLines="5"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText4"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText2"
app:layout_constraintLeft_toLeftOf="#+id/editText2"
android:maxLines="5"
android:minLines="3" />
<Button
android:text="Send S.O.S."
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/button"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:text="Phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView21"
app:layout_constraintLeft_toLeftOf="#+id/textView6"
app:layout_constraintTop_toTopOf="#+id/editText3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/editText3"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/editText4"
app:layout_constraintLeft_toLeftOf="#+id/editText4" />
</ScrollView>
If it says ScrollView can only have one child. Put the children in a single Layout like LinearLayout.
Related
I'm new to working with android layout, I'm building a form app but all my text widgets, dropdowns, and edit text are moving to the left can anyone tell what's wrong?
PS: Code will be appreciated
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="40dp"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="159dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="126dp"
android:text="ERDI"
android:textColor="#000000"
android:textSize="40sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView5" />
<TextView
android:id="#+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="58dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="208dp"
android:text="Spectre Shape"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner3" />
<TextView
android:id="#+id/textView4"
android:layout_width="136dp"
android:layout_height="21dp"
android:layout_marginStart="56dp"
android:layout_marginTop="108dp"
android:layout_marginEnd="179dp"
android:gravity="right"
android:text="Collateral Damage"
android:textAlignment="gravity"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<Spinner
android:id="#+id/spinner5"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView4" />
<TextView
android:id="#+id/textView5"
android:layout_width="118dp"
android:layout_height="25dp"
android:layout_marginStart="56dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="196dp"
android:text="Ground Shaking"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner2" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="128dp"
android:layout_marginEnd="238dp"
android:text="Hazard"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/editTextTextPersonName4"
android:layout_width="252dp"
android:layout_height="46dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="63dp"
android:ems="10"
android:hint="Enter the Height..."
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView18" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="229dp"
android:text="Zone Factor"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner5" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView3" />
<Spinner
android:id="#+id/spinner4"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView8" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="148dp"
android:text="FSI (Floor Space Index)"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner4" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="72dp"
android:layout_marginEnd="215dp"
android:text="Exposure"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editTextTextPersonName4" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="224dp"
android:text="Importance I"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView7" />
<EditText
android:id="#+id/editTextTextPersonName2"
android:layout_width="255dp"
android:layout_height="47dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="60dp"
android:ems="10"
android:hint="Enter the FSI..."
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView10" />
<Spinner
android:id="#+id/spinner7"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView13" />
<Spinner
android:id="#+id/spinner6"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginStart="56dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView12" />
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="89dp"
android:text="Economic Loss Inducing Factors"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner6" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="139dp"
android:text="Life Threatening Factors"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView11" />
<Button
android:id="#+id/postdataBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="147dp"
android:layout_marginTop="108dp"
android:layout_marginEnd="133dp"
android:text="SUBMIT"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner7" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="127dp"
android:layout_marginTop="80dp"
android:layout_marginEnd="108dp"
android:text="Vulnerability"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editTextTextPersonName2" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I'm using constraint layout inside Scroll View layout, I tried various text alignment, widget alignment but the layout still remains to align left.
I Have Used Linear Layout And Updated Your Code to look like a form
If it Helps Accept My Answer !!
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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">
<androidx.appcompat.widget.LinearLayoutCompat
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="40dp"
android:gravity="start"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ERDI"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"
/>
<Spinner
android:id="#+id/spinner3"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"/>
<TextView
android:id="#+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Spectre Shape"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView4"
android:layout_width="136dp"
android:layout_height="21dp"
android:layout_marginTop="20dp"
android:gravity="right"
android:text="Collateral Damage"
android:textAlignment="gravity"
android:textSize="16sp"
android:textStyle="bold"/>
<Spinner
android:id="#+id/spinner5"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"/>
<TextView
android:id="#+id/textView5"
android:layout_width="118dp"
android:layout_height="25dp"
android:layout_marginTop="24dp"
android:text="Ground Shaking"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Hazard"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextTextPersonName4"
android:layout_width="252dp"
android:layout_height="46dp"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="Enter the Height..."
android:inputType="textPersonName"/>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Zone Factor"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<Spinner
android:id="#+id/spinner2"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"/>
<Spinner
android:id="#+id/spinner4"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"/>
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="FSI (Floor Space Index)"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Exposure"
android:textColor="#000000"
android:textSize="20sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Importance I"
android:textSize="16sp"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextTextPersonName2"
android:layout_width="255dp"
android:layout_height="47dp"
android:layout_marginTop="20dp"
android:ems="10"
android:hint="Enter the FSI..."
android:inputType="textPersonName"/>
<Spinner
android:id="#+id/spinner7"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="12dp"/>
<Spinner
android:id="#+id/spinner6"
android:layout_width="254dp"
android:layout_height="41dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="61dp"/>
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="Economic Loss Inducing Factors"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Life Threatening Factors"
android:textAlignment="textEnd"
android:textSize="16sp"
android:textStyle="bold"/>
<Button
android:id="#+id/postdataBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="108dp"
android:text="SUBMIT"
android:layout_gravity="center" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:text="Vulnerability"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</ScrollView>
What I would suggest you to do is to fit everything into a Linear Layout, like this:
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
your code here
</ScrollView>
</LinearLayout>
Also, as someone said in your comments, you should, inside of the ScrollView, use LinearLayout with vertical alignment, and then use proper paddings and margins in order to make the UI look good. You can use gravity and layout-gravity to align every element you want.
I'm working on this project with my classmates, and we decided to do a recipe app. I'm working on the create recipe screen. Instead of adding multiline text for the instructions, I added plain text(1 for each instruction) just so that the appearance of all the recipes will be consistent. At first, it will start of with one instruction and then I want the user to be able to add more from then on.
here's the xml :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:contentDescription="#string/app_name" >
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editTxtRecipeName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:hint="#string/recipe_name"
android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/addThumbnail"
android:importantForAutofill="no" />
<TextView
android:id="#+id/txtCountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:fontFamily="#font/arya_bold"
android:text="#string/cuisine"
android:textColor="#FF6700"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/editTxtRecipeName" />
<Spinner
android:id="#+id/spnCountries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="#+id/txtCountry"
app:layout_constraintStart_toEndOf="#+id/txtCountry"
app:layout_constraintTop_toTopOf="#+id/txtCountry"
tools:ignore="SpeakableTextPresentCheck"
android:entries="#array/countries"/>
<TextView
android:id="#+id/txtEquipment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:fontFamily="#font/arya_bold"
android:text="#string/equipment"
android:textColor="#FF6700"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/txtDuration"
app:layout_constraintTop_toBottomOf="#+id/txtDuration" />
<EditText
android:id="#+id/editTxtEquipment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:hint="#string/_200c_fan_oven"
android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/txtEquipment"
android:importantForAutofill="no" />
<ImageButton
android:id="#+id/btnImgAddEquip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="#004E98"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/editTxtEquipment"
app:srcCompat="#android:drawable/ic_menu_add"
tools:ignore="SpeakableTextPresentCheck" />
<TextView
android:id="#+id/txtIngredients"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="#font/arya_bold"
android:text="#string/ingredients"
android:textColor="#FF6700"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/editTxtEquipment"
app:layout_constraintTop_toBottomOf="#+id/btnImgAddEquip" />
<EditText
android:id="#+id/editTxtIngredient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:hint="#string/_500g_chicken_diced"
android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/txtIngredients"
android:importantForAutofill="no" />
<ImageButton
android:id="#+id/btnImgAddIngr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="#004E98"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/editTxtIngredient"
app:srcCompat="#android:drawable/ic_menu_add"
tools:ignore="SpeakableTextPresentCheck" />
<TextView
android:id="#+id/txtMethod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="#font/arya_bold"
android:text="#string/method"
android:textColor="#FF6700"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/editTxtIngredient"
app:layout_constraintTop_toBottomOf="#+id/btnImgAddIngr" />
<ImageButton
android:id="#+id/btnImgAddMethod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="#004E98"
android:contentDescription="#string/add_image_to_method"
app:layout_constraintEnd_toEndOf="#+id/editTxtMethod"
app:layout_constraintHorizontal_bias="0.39"
app:layout_constraintStart_toStartOf="#+id/editTxtMethod"
app:layout_constraintTop_toBottomOf="#+id/editTxtMethod"
app:srcCompat="#android:drawable/ic_menu_gallery" />
<ImageButton
android:id="#+id/imageButton6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:backgroundTint="#004E98"
android:contentDescription="#string/add_another_step"
app:layout_constraintBottom_toBottomOf="#+id/btnImgAddMethod"
app:layout_constraintStart_toEndOf="#+id/btnImgAddMethod"
app:layout_constraintTop_toTopOf="#+id/btnImgAddMethod"
app:srcCompat="#android:drawable/ic_menu_add" />
<ImageView
android:id="#+id/viewThumbnail"
android:layout_width="149dp"
android:layout_height="149dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#android:drawable/ic_menu_gallery" />
<Button
android:id="#+id/addThumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="#004E98"
android:text="#string/thumbnail"
app:layout_constraintEnd_toEndOf="#+id/viewThumbnail"
app:layout_constraintStart_toStartOf="#+id/viewThumbnail"
app:layout_constraintTop_toBottomOf="#+id/viewThumbnail" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="95dp"
android:backgroundTint="#004E98"
android:text="#string/video"
app:layout_constraintBottom_toBottomOf="#+id/addThumbnail"
app:layout_constraintStart_toEndOf="#+id/addThumbnail"
app:layout_constraintTop_toTopOf="#+id/addThumbnail"
app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="#+id/viewVideo"
android:layout_width="164dp"
android:layout_height="149dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.743"
app:layout_constraintStart_toEndOf="#+id/viewThumbnail"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#android:drawable/ic_menu_slideshow" />
<TextView
android:id="#+id/txtCultureDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="#font/arya_bold"
android:text="#string/personal_story"
android:textColor="#FF6700"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/btnImgAddMethod" />
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="64dp"
android:backgroundTint="#004E98"
android:text="#string/button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editPersonalStory" />
<EditText
android:id="#+id/editPersonalStory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:gravity="start|top"
android:hint="#string/tell_us_about_your_culture_country"
android:inputType="textMultiLine"
android:minHeight="48dp"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/txtCultureDescription"
android:importantForAutofill="no" />
<EditText
android:id="#+id/editTxtMethod"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:gravity="start|top"
android:hint="#string/pan_fry_chicken_fr_10_mins"
android:inputType="textMultiLine"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toBottomOf="#+id/txtMethod"
android:importantForAutofill="no" />
<TextView
android:id="#+id/txtDuration"
android:layout_width="90dp"
android:layout_height="0dp"
android:layout_marginTop="24dp"
android:fontFamily="#font/arya_bold"
android:text="#string/approx_cooking_time"
android:textColor="#FF6700"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="#+id/txtCountry"
app:layout_constraintTop_toBottomOf="#+id/txtCountry" />
<Spinner
android:id="#+id/spnHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="#+id/txtDuration"
app:layout_constraintStart_toEndOf="#+id/txtDuration"
app:layout_constraintTop_toTopOf="#+id/txtDuration"
tools:ignore="SpeakableTextPresentCheck"
android:entries="#array/hours"/>
<TextView
android:id="#+id/txtHours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="#string/hrs"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/spnHours"
app:layout_constraintStart_toEndOf="#+id/spnHours"
app:layout_constraintTop_toTopOf="#+id/spnHours" />
<Spinner
android:id="#+id/spnMinutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="#+id/spnHours"
app:layout_constraintStart_toEndOf="#+id/txtHours"
app:layout_constraintTop_toTopOf="#+id/spnHours"
tools:ignore="SpeakableTextPresentCheck"
android:entries="#array/minutes"/>
<TextView
android:id="#+id/txtMinutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="#string/mins"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/spnMinutes"
app:layout_constraintStart_toEndOf="#+id/spnMinutes"
app:layout_constraintTop_toTopOf="#+id/spnMinutes" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="395dp" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="16dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I originally thought I would be able to write to the activity_main.xml using the MainActivity.java, but apparently the xml files are read-only. I know the answer sounds obvious after typing that, but is there a way to dynamically change the layout?
What you want is to create a dynamic list with a RecyclerView. There are some sample apps at the bottom to help you get started.
If you have any questions after reading feel free to edit your post or create another one.
RecylerView is the correct way to do it . But since you are a beginner to android i presume use ArrayAdapter for any list like elements.
"change the layout dynamically" is a bit broad but use
// view is any element in your code
view.visibility = View.Visible
view.visibility = View.GONE
XML based layout works on events ..what i mean by that is something happens when you interact . So for example if you want an image to disappear on the click of a button you would do something like
view.setOnCLickListener{
imageview.visibility = View.GONE
}
I am a beginner in native android programming. Would like to seek some guidance and help to get rid of this gap in between the toolbar and my recycler view. Read through some write-ups on people who faced the same issue but majority of these had included a "Coordinator Layout" or "layout_gravity". However, I did not have those in my code. Tried many other ways but couldn't make it work.
Here is a picture that is based on the code! The embedded picture shows a better contrast for the gap. Sorry my account doesn't allow any embedding of photos yet.
Here is my code for the parent recycler view.
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvProfile"
android:layout_width="403dp"
android:layout_height="match_parent"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp" />
Here is the code for my individual item layout.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/profileImage"
android:layout_width="111dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="29dp"
android:background="#drawable/profile"></ImageView>
<TextView
android:id="#+id/profileUserName"
android:layout_width="wrap_content"
android:layout_height="29dp"
android:layout_alignParentTop="true"
android:layout_marginStart="4dp"
android:layout_marginTop="1dp"
android:layout_toEndOf="#+id/profileImage"
android:text="User Name"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:id="#+id/changeProfilePicture"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_below="#+id/profileUserName"
android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:layout_toEndOf="#+id/profileImage"
android:background="#color/zxing_transparent"
android:text="Change Profile Picture"
android:textAllCaps="false"
android:textColor="#color/textColorLight"
android:textSize="20sp"
android:textStyle="normal"></Button>
<Button
android:id="#+id/changePasswordBtn"
android:layout_width="wrap_content"
android:layout_height="23dp"
android:layout_below="#+id/changeProfilePicture"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:layout_toEndOf="#+id/profileImage"
android:background="#color/zxing_transparent"
android:text="Change Password"
android:textAllCaps="false"
android:textColor="#color/textColorLight"
android:textSize="20sp"
android:textStyle="normal"></Button>
<TextView
android:id="#+id/accountbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/profileImage"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="1dp"
android:layout_marginTop="-1dp"
android:layout_marginEnd="0dp"
android:background="#color/primarylighest"
android:padding="5dp"
android:paddingStart="30dp"
android:text="Account"
android:textColor="#color/colorPrimary"
android:textSize="25sp" />
<TextView
android:id="#+id/pointsTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/accountbar"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Points"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<TextView
android:id="#+id/pointsDisplay"
android:layout_width="157dp"
android:layout_height="wrap_content"
android:layout_below="#+id/accountbar"
android:layout_marginStart="131dp"
android:layout_marginTop="6dp"
android:layout_toEndOf="#+id/pointsTxt"
android:text="42 Points"
android:textColor="#color/textColorLight"
android:textSize="20sp"></TextView>
<TextView
android:id="#+id/orderHistoryTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/pointsTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="0dp"
android:text="Order History"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:id="#+id/orderHistBtn"
android:layout_width="33dp"
android:layout_height="28dp"
android:layout_below="#+id/pointsDisplay"
android:layout_alignParentEnd="true"
android:layout_marginStart="178dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="15dp"
android:layout_toEndOf="#+id/orderHistoryTxt"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/txtExpenseTracker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="1dp"
android:text="Expense Tracker"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_below="#+id/pointsDisplay"
android:layout_alignParentEnd="true"
android:layout_marginStart="141dp"
android:layout_marginTop="44dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="#+id/txtExpenseTracker"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/txtCurrencyConvertor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="37dp"
android:text="Currency Convertor"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="30dp"
android:layout_height="24dp"
android:layout_below="#+id/pointsDisplay"
android:layout_alignParentEnd="true"
android:layout_marginStart="176dp"
android:layout_marginTop="210dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="#+id/txtPrivacyPolicy"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/othersbar"
android:layout_width="410dp"
android:layout_height="46dp"
android:layout_below="#+id/profileImage"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="1dp"
android:layout_marginTop="206dp"
android:layout_marginEnd="0dp"
android:background="#color/primarylighest"
android:padding="5dp"
android:paddingStart="30dp"
android:text="Others"
android:textColor="#color/colorPrimary"
android:textSize="25sp" />
<TextView
android:id="#+id/txtShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="140dp"
android:text="Share Krysjay with friends"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_below="#+id/othersbar"
android:layout_alignParentEnd="true"
android:layout_marginStart="37dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="#+id/txtShare"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/txtPrivacyPolicy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="172dp"
android:text="Privacy Policy"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_below="#+id/othersbar"
android:layout_alignParentEnd="true"
android:layout_marginStart="110dp"
android:layout_marginTop="-97dp"
android:layout_marginEnd="15dp"
android:layout_toEndOf="#+id/txtCurrencyConvertor"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<TextView
android:id="#+id/txtTermsCons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/orderHistoryTxt"
android:layout_alignParentStart="true"
android:layout_marginStart="35dp"
android:layout_marginTop="205dp"
android:text="Terms & Conditions"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"></TextView>
<Button
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_below="#+id/othersbar"
android:layout_alignParentEnd="true"
android:layout_marginStart="105dp"
android:layout_marginTop="66dp"
android:layout_marginEnd="17dp"
android:layout_toEndOf="#+id/txtTermsCons"
android:background="#drawable/profile_back"
android:rotation="180"></Button>
<Button
android:id="#+id/signOutBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txtPrivacyPolicy"
android:layout_alignParentStart="true"
android:layout_marginStart="0dp"
android:layout_marginTop="27dp"
android:layout_marginBottom="132dp"
android:background="#color/zxing_transparent"
android:outlineAmbientShadowColor="#color/colorPrimaryDark"
android:paddingStart="30dp"
android:text="Sign Out"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#color/colorPrimary"
android:textSize="25sp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Have you tried to remove this line of code from your imageView?
android:layout_marginTop="67dp"
<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">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/profileImage"
android:layout_width="111dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#drawable/profile"></ImageView>
<TextView
android:id="#+id/accountbar"
android:layout_width="410dp"
android:layout_height="46dp"
android:background="#color/primarylighest"
android:padding="5dp"
android:paddingStart="30dp"
android:text="Account"
android:textColor="#color/colorPrimary"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/profileImage"/>
<TextView
android:id="#+id/profileUserName"
android:layout_width="wrap_content"
android:layout_height="29dp"
android:text="User Name"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#id/accountbar"
app:layout_constraintTop_toBottomOf="#id/profileImage"></TextView>
<Button
android:id="#+id/changeProfilePicture"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_marginStart="4dp"
android:background="#color/zxing_transparent"
android:text="Change Profile Picture"
android:textAllCaps="false"
android:textColor="#color/textColorLight"
android:textSize="20sp"
android:textStyle="normal"
app:layout_constraintEnd_toStartOf="#id/pointsDisplay"
app:layout_constraintHorizontal_bias="0.516"
app:layout_constraintStart_toEndOf="#id/pointsTxt"
app:layout_constraintTop_toBottomOf="#id/accountbar"></Button>
<Button
android:id="#+id/changePasswordBtn"
android:layout_width="wrap_content"
android:layout_height="23dp"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:background="#color/zxing_transparent"
android:text="Change Password"
android:textAllCaps="false"
android:textColor="#color/textColorLight"
android:textSize="20sp"
android:textStyle="normal"
app:layout_constraintEnd_toStartOf="#id/pointsDisplay"
app:layout_constraintStart_toEndOf="#id/pointsTxt"
app:layout_constraintTop_toBottomOf="#id/changeProfilePicture"></Button>
<TextView
android:id="#+id/pointsTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="8dp"
android:text="Points"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/accountbar"></TextView>
<TextView
android:id="#+id/pointsDisplay"
android:layout_width="157dp"
android:layout_height="wrap_content"
android:layout_marginStart="131dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="15dp"
android:text="42 Points"
android:textColor="#color/textColorLight"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/pointsTxt"
app:layout_constraintTop_toBottomOf="#id/accountbar"></TextView>
<TextView
android:id="#+id/orderHistoryTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Order History"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/pointsTxt"></TextView>
<Button
android:id="#+id/orderHistBtn"
android:layout_width="33dp"
android:layout_height="28dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/orderHistoryTxt"
app:layout_constraintTop_toBottomOf="#id/changePasswordBtn"></Button>
<TextView
android:id="#+id/txtExpenseTracker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Expense Tracker"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/orderHistoryTxt"></TextView>
<Button
android:id="#+id/btnExpenseTracker"
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/txtExpenseTracker"
app:layout_constraintTop_toBottomOf="#id/orderHistBtn"></Button>
<TextView
android:id="#+id/txtCurrencyConvertor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Currency Convertor"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtExpenseTracker"></TextView>
<Button
android:id="#+id/button"
android:layout_width="30dp"
android:layout_height="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/txtPrivacyPolicy"
app:layout_constraintTop_toBottomOf="#id/btnShareWithFriends"></Button>
<TextView
android:id="#+id/othersbar"
android:layout_width="410dp"
android:layout_height="46dp"
android:layout_marginTop="4dp"
android:background="#color/primarylighest"
android:padding="5dp"
android:paddingStart="30dp"
android:text="Others"
android:textColor="#color/colorPrimary"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtCurrencyConvertor" />
<TextView
android:id="#+id/txtShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Share Krysjay with friends"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/othersbar"></TextView>
<Button
android:id="#+id/btnShareWithFriends"
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/txtShare"
app:layout_constraintTop_toBottomOf="#id/othersbar"></Button>
<TextView
android:id="#+id/txtPrivacyPolicy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Privacy Policy"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtShare"></TextView>
<Button
android:id="#+id/btnCurrencyCovertor"
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#id/txtCurrencyConvertor"
app:layout_constraintTop_toBottomOf="#id/btnExpenseTracker"></Button>
<TextView
android:id="#+id/txtTermsCons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginTop="4dp"
android:text="Terms & Conditions"
android:textColor="#color/colorPrimaryDark"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtPrivacyPolicy"></TextView>
<Button
android:id="#+id/btnTermsCond"
android:layout_width="32dp"
android:layout_height="31dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="15dp"
android:background="#drawable/profile_back"
android:rotation="180"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#+id/txtTermsCons"
app:layout_constraintTop_toBottomOf="#+id/button"></Button>
<Button
android:id="#+id/signOutBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="#+id/txtPrivacyPolicy"
android:layout_alignParentStart="true"
android:layout_marginTop="4dp"
android:background="#color/zxing_transparent"
android:outlineAmbientShadowColor="#color/colorPrimaryDark"
android:paddingStart="30dp"
android:text="Sign Out"
android:textAlignment="textStart"
android:textAllCaps="false"
android:textColor="#color/colorPrimary"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/txtTermsCons" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Unable to place a textview or any object under half of a screen
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.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" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/content_main" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/gender"
android:layout_width="96dp"
android:layout_height="49dp"
android:layout_gravity="center"
android:paddingTop="30dp"
android:text="GENDER"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_red_dark"
android:textStyle="bold|italic"
android:typeface="serif"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.295"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.102" />
<TextView
android:id="#+id/tv4"
android:layout_width="96dp"
android:layout_height="49dp"
android:layout_gravity="center"
android:layout_marginTop="116dp"
android:paddingTop="30dp"
android:text="HEIGHT"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_red_dark"
android:textStyle="bold|italic"
android:typeface="serif"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.295"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<org.angmarch.views.NiceSpinner
android:id="#+id/weight_spinner"
android:layout_width="148dp"
android:layout_height="52dp"
android:layout_marginBottom="12dp"
app:layout_constraintBottom_toTopOf="#+id/weight_et"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.222"
app:layout_constraintStart_toEndOf="#+id/tv3" />
<EditText
android:id="#+id/weight_et"
android:layout_width="139dp"
android:layout_height="38dp"
android:layout_gravity="center"
android:layout_marginTop="28dp"
android:ems="10"
android:fadingEdgeLength="10dp"
android:hint="Enter Weight"
android:inputType="numberDecimal"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.283"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv3" />
<TextView
android:id="#+id/tv3"
android:layout_width="107dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:paddingTop="30dp"
android:text="WEIGHT"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_red_dark"
android:textStyle="bold|italic"
android:typeface="serif"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.305"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/height_et" />
<Button
android:id="#+id/ib1"
android:layout_width="158dp"
android:layout_height="51dp"
android:layout_gravity="center"
android:layout_marginTop="28dp"
android:background="#android:color/holo_blue_dark"
android:capitalize="words"
android:fadingEdge="vertical"
android:longClickable="true"
android:text="Calculate"
android:textColor="#android:color/holo_green_light"
android:textStyle="bold|italic"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/weight_et" />
<org.angmarch.views.NiceSpinner
android:id="#+id/height_spinner"
android:layout_width="148dp"
android:layout_height="54dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="#+id/height_et"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.148"
app:layout_constraintStart_toEndOf="#+id/tv4" />
<EditText
android:id="#+id/height_et"
android:layout_width="137dp"
android:layout_height="43dp"
android:layout_gravity="center"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="Enter Height"
android:inputType="numberDecimal"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.281"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv4"/>
<TextView
android:id="#+id/result_tv"
android:layout_width="200dp"
android:layout_height="66dp"
android:layout_gravity="center"
android:paddingTop="20dp"
android:text=""
android:textAlignment="center"
android:textColor="#android:color/holo_orange_dark"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.027"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ib1"
app:layout_constraintVertical_bias="1.0" />
<EditText
android:id="#+id/ft_in_et"
android:layout_width="158dp"
android:layout_height="44dp"
android:layout_marginBottom="20dp"
android:ems="10"
android:hint=""
android:inputType="numberDecimal"
android:textAlignment="center"
android:visibility="gone"
android:enabled="false"
app:layout_constraintBottom_toTopOf="#+id/weight_spinner"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.27"
app:layout_constraintStart_toEndOf="#+id/height_et" />
<EditText
android:id="#+id/st_lb_et"
android:layout_width="149dp"
android:layout_height="41dp"
android:ems="10"
android:hint="lb"
android:inputType="numberDecimal"
android:textAlignment="center"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="#+id/ib1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.076"
app:layout_constraintStart_toEndOf="#+id/weight_et" />
<TextView
android:id="#+id/ideal_weight"
android:layout_width="171dp"
android:layout_height="64dp"
android:gravity="center"
android:text=""
android:textAlignment="center"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.982"
app:layout_constraintStart_toStartOf="#+id/result_tv" />
<org.angmarch.views.NiceSpinner
android:id="#+id/gender_spinner"
android:layout_width="187dp"
android:layout_height="50dp"
app:layout_constraintBottom_toTopOf="#+id/tv4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.982"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
app:adSize="BANNER"
app:adUnitId="ca-app-pub-3940256099942544/6300978111"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"></com.google.android.gms.ads.AdView>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:backgroundTint="#009688"
app:srcCompat="#drawable/ic_reset" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
As you can see in the image that half of the screen is uneditable
As you can see in the image that half of the screen is uneditable
As you can see in the image that half of the screen is uneditable
[Here is an image of layout]
https://i.stack.imgur.com/OKygh.jpg
Problem is inside of your ConstraintLayout. You use wrong constraints.
Fixed Some:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/gender"
android:layout_width="96dp"
android:layout_height="49dp"
android:layout_gravity="center"
android:paddingTop="30dp"
android:text="GENDER"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_red_dark"
android:textStyle="bold|italic"
android:typeface="serif"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.295"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.102" />
<TextView
android:id="#+id/tv4"
android:layout_width="96dp"
android:layout_height="49dp"
android:layout_gravity="center"
android:layout_marginTop="116dp"
android:paddingTop="30dp"
android:text="HEIGHT"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_red_dark"
android:textStyle="bold|italic"
android:typeface="serif"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.295"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<org.angmarch.views.NiceSpinner
android:id="#+id/weight_spinner"
android:layout_width="148dp"
android:layout_height="52dp"
android:layout_marginBottom="12dp"
app:layout_constraintBottom_toTopOf="#+id/weight_et"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.222"
app:layout_constraintStart_toEndOf="#+id/tv3" />
<EditText
android:id="#+id/weight_et"
android:layout_width="139dp"
android:layout_height="38dp"
android:layout_gravity="center"
android:layout_marginTop="28dp"
android:ems="10"
android:fadingEdgeLength="10dp"
android:hint="Enter Weight"
android:inputType="numberDecimal"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.283"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv3" />
<TextView
android:id="#+id/tv3"
android:layout_width="107dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:paddingTop="30dp"
android:text="WEIGHT"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/holo_red_dark"
android:textStyle="bold|italic"
android:typeface="serif"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.305"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/height_et" />
<Button
android:id="#+id/ib1"
android:layout_width="158dp"
android:layout_height="51dp"
android:layout_gravity="center"
android:layout_marginTop="28dp"
android:background="#android:color/holo_blue_dark"
android:capitalize="words"
android:fadingEdge="vertical"
android:longClickable="true"
android:text="Calculate"
android:textColor="#android:color/holo_green_light"
android:textStyle="bold|italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/weight_et" />
<org.angmarch.views.NiceSpinner
android:id="#+id/height_spinner"
android:layout_width="148dp"
android:layout_height="54dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="#+id/height_et"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.148"
app:layout_constraintStart_toEndOf="#+id/tv4" />
<EditText
android:id="#+id/height_et"
android:layout_width="137dp"
android:layout_height="43dp"
android:layout_gravity="center"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="Enter Height"
android:inputType="numberDecimal"
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.281"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv4"/>
<TextView
android:id="#+id/result_tv"
android:layout_width="200dp"
android:layout_height="66dp"
android:layout_gravity="center"
android:paddingTop="20dp"
android:text="Result"
android:textAlignment="center"
android:textColor="#android:color/holo_orange_dark"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.027"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ib1"
app:layout_constraintVertical_bias="1.0" />
<EditText
android:id="#+id/ft_in_et"
android:layout_width="158dp"
android:layout_height="44dp"
android:layout_marginBottom="20dp"
android:ems="10"
android:hint="lb"
android:inputType="numberDecimal"
android:textAlignment="center"
android:enabled="false"
app:layout_constraintBottom_toTopOf="#+id/weight_spinner"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.27"
app:layout_constraintStart_toEndOf="#+id/height_et" />
<EditText
android:id="#+id/st_lb_et"
android:layout_width="149dp"
android:layout_height="41dp"
android:ems="10"
android:hint="lb"
android:inputType="numberDecimal"
android:textAlignment="center"
app:layout_constraintTop_toBottomOf="#+id/weight_spinner"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.076"
app:layout_constraintStart_toEndOf="#+id/weight_et" />
<TextView
android:id="#+id/ideal_weight"
android:layout_width="171dp"
android:layout_height="64dp"
android:gravity="center"
android:text=""
android:textAlignment="center"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/adView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.982"
app:layout_constraintStart_toStartOf="#+id/result_tv" />
<org.angmarch.views.NiceSpinner
android:id="#+id/gender_spinner"
android:layout_width="187dp"
android:layout_height="50dp"
app:layout_constraintBottom_toTopOf="#+id/tv4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.982"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
app:adSize="BANNER"
app:adUnitId="ca-app-pub-3940256099942544/6300978111"
app:layout_constraintTop_toBottomOf="#+id/result_tv"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:backgroundTint="#009688"
app:srcCompat="#android:drawable/ic_menu_search" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Output:
Hi please add fillViewport as true in scrollview.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"/>
I am trying since 2 days ago to create this simple layout: it is not exactly equal, but it is near that what I want.
When I try to set the scrollView on my constraint layout I get always this messy
even if I constraint all my elements, I don't know how to organize the things at the moment, I am really confused about this.
here is my xml:
<ScrollView 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="wrap_content"
tools:context=".PhotosForPlant">
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.afcosta.inesctec.pt.android.PhotosForPlant"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp">
<ImageView
android:id="#+id/plantImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/color_cursor_white"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="41dp" />
<TextView
android:id="#+id/descricaoTit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descrição"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="582dp" />
<TextView
android:id="#+id/specieDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="622dp" />
<TextView
android:id="#+id/Family"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Familia"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="458dp" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Genre"
tools:layout_editor_absoluteX="24dp"
tools:layout_editor_absoluteY="389dp" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Espécie"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="309dp" />
<TextView
android:id="#+id/FamilyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="96dp"
tools:layout_editor_absoluteY="458dp" />
<TextView
android:id="#+id/GenreName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="96dp"
tools:layout_editor_absoluteY="389dp" />
<TextView
android:id="#+id/SpecieName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="96dp"
tools:layout_editor_absoluteY="309dp" />
<android.support.v7.widget.RecyclerView
android:id="#+id/gallery"
android:layout_width="408dp"
android:layout_height="111dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="141dp" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
As per your requirement i created sample layout so you can design same according to that i used nestedscrollview rather than scrollview and also applied constraint for all views
<android.support.v4.widget.NestedScrollView 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:fillViewport="true"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.afcosta.inesctec.pt.android.PhotosForPlant"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp">
<ImageView
android:id="#+id/plantImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/smile"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.573"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/toolbar2" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViLeft"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/plantImage"
android:layout_marginStart="8dp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewDetail1"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="#+id/textView3"
android:layout_marginStart="8dp" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewDetail2"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView13" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewDetail3"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView14" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/plantImage"
android:layout_marginEnd="8dp" />
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewBold1"
android:textStyle="bold"
android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="#+id/textView3"
app:layout_constraintLeft_toRightOf="#+id/textView5"
android:layout_marginStart="20dp" />
<TextView
android:id="#+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewBold2"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="#+id/textView6"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView13" />
<TextView
android:id="#+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextViewBold3"
app:layout_constraintLeft_toRightOf="#+id/textView7"
android:textStyle="bold"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView14" />
<TextView
android:id="#+id/textView16"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView TextView TextView TextView TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.0"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView15" />
<android.support.v7.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:id="#+id/recyclerview"
app:layout_constraintTop_toBottomOf="#+id/textView16"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteX="8dp" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
here is design and blue print
NOTE: You are using RecyclerView in ScrollView which is not recommended.