I am facing trouble of getting my layouts works on all Android devices with the same dimensions. I noticed that every time a friend installs my app, the Buttons and TextViews are changing their initial positions, going up or down some times or making the text inside of it wrapping instead of display it all ( i will attach some code of one of the layouts as an example ). I need some good documentation and/or tutorials for the best layout designs.
Layout example:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:background="#drawable/dashboardsec"
tools:context=".main.DashboardActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#009B3232"
android:orientation="vertical"
android:paddingEnd="5dp"
android:textAlignment="textEnd">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="66dp"
android:layout_gravity="center_horizontal"
android:layout_marginStart="33dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="40dp"
android:background="#color/common_google_signin_btn_text_dark_disabled"
android:fontFamily="sans-serif-thin"
android:gravity="center"
android:text="مرحباً بك "
android:textAlignment="textStart"
android:textColor="#color/orange1"
android:textSize="24sp" />
<Button
android:id="#+id/newsBtn"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" الاخبار "
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textColorHint="#00AF2B2B"
android:textSize="22sp" />
<Button
android:id="#+id/formatsBtn"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" فورمات جاهزة و كتب رسمية"
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/storagebtN"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" فيديو و صور "
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/exchangeBtn"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" طلبات استبدال المراكز "
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/askBtn"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" الخرائط و الصرافات الالية "
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/phonesBtn"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" فهرست الهواتف"
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/websitsbtn"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" صفحات تابعة لللجنة"
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/profilebtn"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:shadowColor="#color/common_google_signin_btn_text_dark_focused"
android:text=" أدوات مفيدة coming soon"
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/button1"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" السوق coming soon"
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/usersaccount"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" التحكم بالاعضاء"
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/sendimalsBtn"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" ارسال بريد للادارة"
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
<Button
android:id="#+id/button"
android:layout_width="385dp"
android:layout_height="wrap_content"
android:background="#009B3232"
android:fontFamily="sans-serif-thin"
android:text=" تسجيل خروج "
android:textAlignment="textStart"
android:textColor="#DCDFE9"
android:textSize="22sp" />
</LinearLayout>
</ScrollView>
This is happening because you are using fixed size dimensions on your views, and because different phones got different screen sizes you will see this difference.
As mentioned in the comment section- you can use ConstraintLayout to create one layout to support all different screen sizes.
Here is an example of your wanted layout (similar in the look of it any way):
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="ltr"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button6" />
<Button
android:id="#+id/button7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button5" />
<Button
android:id="#+id/button8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button7" />
<Button
android:id="#+id/button9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button10"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button8" />
<Button
android:id="#+id/button10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button11"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button9" />
<Button
android:id="#+id/button11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button12"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button10" />
<Button
android:id="#+id/button12"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button13"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button11" />
<Button
android:id="#+id/button13"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button14"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button12" />
<Button
android:id="#+id/button14"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button15"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button13" />
<Button
android:id="#+id/button15"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button16"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button14" />
<Button
android:id="#+id/button16"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button17"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button15" />
<Button
android:id="#+id/button17"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="#+id/button18"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button16" />
<Button
android:id="#+id/button18"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button17" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
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 work on an app here where some user data needs to be filled up. The data is afterwards needed to be placed into another activity each in their unique TextViews. Here is my activity Ui
Here is my XML code:
<androidx.constraintlayout.widget.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=".PreviewActivity">
<TextView
android:id="#+id/textView4"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="20dp"
android:text="Name:"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<View
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#3F230D"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView4"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/textView5"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Phone num:"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/textView4"
app:layout_constraintTop_toBottomOf="#+id/textView4"
app:layout_constraintVertical_bias="0.0" />
<View
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#3F230D"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView5"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/textView9"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Date:"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/textView8"
app:layout_constraintTop_toBottomOf="#+id/textView8"
app:layout_constraintVertical_bias="0.0" />
<View
android:id="#+id/view"
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#3F230D"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView9"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/textView6"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Kind of order:"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/textView5"
app:layout_constraintTop_toBottomOf="#+id/textView5"
app:layout_constraintVertical_bias="0.0" />
<View
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#3F230D"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView6"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/textView7"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Price:"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/textView6"
app:layout_constraintVertical_bias="0.065" />
<View
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#3F230D"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView7"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/textView8"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Deposit:"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/textView7"
app:layout_constraintTop_toBottomOf="#+id/textView7"
app:layout_constraintVertical_bias="0.0" />
<View
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#3F230D"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView8"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/tv_name"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:text="Jett Kavinsky"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/textView4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/textView4"
app:layout_constraintTop_toTopOf="#+id/textView4" />
<TextView
android:id="#+id/tv_number"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:text="077364063"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/textView5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/textView5"
app:layout_constraintTop_toTopOf="#+id/textView5" />
<TextView
android:id="#+id/tv_kind"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="Some text here"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/textView6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/textView6"
app:layout_constraintTop_toTopOf="#+id/textView6" />
<TextView
android:id="#+id/tv_price"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:text="150000"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/textView7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/textView7"
app:layout_constraintTop_toTopOf="#+id/textView7" />
<TextView
android:id="#+id/tv_deposit"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:text="20000"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/textView8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/textView8"
app:layout_constraintTop_toTopOf="#+id/textView8" />
<TextView
android:id="#+id/tv_date"
style="#style/TextAppearance.AppCompat.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:text="04․08․2021"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/textView9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/textView9"
app:layout_constraintTop_toTopOf="#+id/textView9" />
</androidx.constraintlayout.widget.ConstraintLayout>
the 3rd parameter should be a two-lined text, but the second line should begin under the "kind of order" and not the "some text here" (as it drops under the "some text here" right now). How can I change this? Thank you from ahead.
You can use \n to new line like this:
android:text="text\nmore text"
I created a custom view extending the AutoCompleteTextView. Also I have custom attributes related to that. When I set the custom string attribute value in the layout, the constraint layout design screen preview stops properly working. When I remove the custom string attribute, the constraint layout works properly. This only takes place at design time, there is no problem at run time. I reinstalled and updated Android Studio but it didn't help me. My codes and screenshots are below:
broken view when setting custom attribute named model_field
attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="DATV">
<attr name="model_field" format="string"/>
<attr name="search_type" format="enum">
<enum name="never" value="0"/>
<enum name="always" value="1"/>
<enum name="depended" value="2"/>
</attr>
</declare-styleable>
</resources>
Layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.constraint.ConstraintLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- TODO: Update blank fragment layout -->
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/multiAutoCompleteTextView2"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView13"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/e_mail_adresi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView16" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView4"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView7"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView12"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/telefon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView17" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView3"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView8" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintTop_toBottomOf="#+id/textView11"
android:layout_marginTop="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/tc_kimlik_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView18" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView2"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<TextView
android:text="#string/arac_bilgileri"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/textView2"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="16dp" android:textStyle="bold"/>
<TextView
android:text="#string/marka"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView2" android:labelFor="#+id/carBrandDATV"/>
<tr.com.universe.raportiz.lib.views.CarBrandDATV
app:model_field="#string/CarBrand_name"
app:search_type="always"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/carBrandDATV"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView3"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"
/>
<TextView
android:text="#string/model"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView4" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/carBrandDATV"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
/>
<tr.com.universe.raportiz.lib.views.CarModelDATV
app:model_field="#string/CarModel_name"
app:search_type="depended"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/carModelDATV"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView4"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/plaka"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/carModelDATV" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"/>
<tr.com.universe.raportiz.lib.views.CarDATV
app:model_field="#string/Car_plate_no"
app:search_type="always"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/plateNoDATV"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView6"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/sasi_numaras"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView7" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/plateNoDATV" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"/>
<tr.com.universe.raportiz.lib.views.CarDATV
app:model_field="#string/Car_chassis_no"
app:search_type="always"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView5"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView7"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/motor_numarasi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView8" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView5"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<tr.com.universe.raportiz.lib.views.CarDATV
app:model_field="#string/Car_engine_no"
app:search_type="always"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView8"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/arac_sahibi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView9"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:textStyle="bold"/>
<TextView
android:text="#string/ad_soyad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView10" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView9" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView2"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView10"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/tc_kimlik_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView11" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView2"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView3" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintTop_toBottomOf="#+id/textView11"
android:layout_marginTop="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/telefon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView12" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView3"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView4"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView12"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/e_mail_adresi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView13" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView4"/>
<MultiAutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/multiAutoCompleteTextView"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView13"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/alici_bilgileri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView14" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/multiAutoCompleteTextView"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
android:textStyle="bold"/>
<TextView
android:text="#string/ad_soyad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView15" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView14"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView6" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView15" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/tc_kimlik_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView19" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView6"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView9" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView19" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/telefon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView20" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView9"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView10"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/textView20"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:background="#drawable/edittext_selector"/>
<TextView
android:text="#string/e_mail_adresi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView21" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/autoCompleteTextView10"/>
<AutoCompleteTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/autoCompleteTextView11" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/textView21" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:background="#drawable/edittext_selector"/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
When I remove the model_field attributes, the preview works properly like below
the view when I remove the custom attributes named "model_field"
After looking up various answers and suggestions on the site, I implemented a custom toolbar in my app instead of using the default ActionBar. For the most part, it works fine, however, one thing that is different from the standard action bar is that it auto-hides whenever I scroll. In the default ActionBar, it was always visible on the activity regardless of whether I was scrolling or not. Can anyone please explain how to implement this behavior in the custom toolbar as well? I have attached my xml below:
EDIT: I have tried moving the toolbar out of the scrollview which fixes the toolbar but then when I scroll, then other views in my activity also overlap on the toolbar because the top-most view is bound to the scrollview and other views are bound to it. So, the current implementation is better than the overlapping problem, but it is still not the solution I desire.
<?xml version="1.0" encoding="utf-8"?>
<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=".MainActivity">
<ScrollView
android:id="#+id/sc1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/searchBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:ems="10"
android:hint="Search..."
android:textColorHint="#color/myWhite"
android:inputType="textPersonName"
android:textColor="#color/myWhite"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/subtitleBtn" />
<android.support.v7.widget.Toolbar
android:id="#+id/myToolbar"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:titleTextColor="#color/myWhite"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:contentInsetLeft="48dp"
android:contentInsetStart="48dp"
app:titleMarginStart="24dp"
app:contentInsetLeft="12dp"
app:contentInsetStart="12dp"
android:contentInsetRight="0dp"
android:contentInsetEnd="0dp"
app:contentInsetRight="0dp"
app:contentInsetEnd="0dp"/>
<Button
android:id="#+id/splitDrawableBackgroundBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Set Split Drawable Background"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.517"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/stackedDrawableBackgroundBtn" />
<Button
android:id="#+id/subtitleBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Show Subtitle"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/iconBtn" />
<Button
android:id="#+id/iconBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Set Icon"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/alternateBackBtn" />
<Button
android:id="#+id/alternateBackBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Set Alternate Back Button"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/hideBarBtn" />
<Button
android:id="#+id/hideBarBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Hide Action Bar"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/elevationBtn" />
<Button
android:id="#+id/elevationBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Set Elevation"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/logoBtn" />
<Button
android:id="#+id/logoBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Set Logo"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/hideAllBtn" />
<Button
android:id="#+id/hideAllBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Hide Everything"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/hideBackBtn" />
<Button
android:id="#+id/hideBackBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Hide Back Button"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/splitDrawableBackgroundBtn" />
<Button
android:id="#+id/stackedDrawableBackgroundBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Set Stacked Drawable Background"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/drawableBackgroundBtn" />
<Button
android:id="#+id/drawableBackgroundBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Set Drawable Background"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/customViewBtn" />
<Button
android:id="#+id/customViewBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Show Custom View"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/hideOffsetBtn" />
<Button
android:id="#+id/hideOffsetBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Hide Offset"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/backBtn" />
<Button
android:id="#+id/backBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:text="Show back button"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/titleBtn" />
<Button
android:id="#+id/titleBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="88dp"
android:text="Set Title"
android:fontFamily="#font/roboto_black"
android:textAllCaps="false"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
Since the toolbar is inside the scrollview it will scroll.
Take it out and constraint it to the top of the Constraint Layout.
Please place the toolbar before scrollview. Then it becomes not scrollable and the rest of the area is scrollable
move your toolbar to our side of the scroll view
your view hierarchy should be something like this :
<LinearLayout>
<Toolbar/>
<FrameLayout>
<ScrollView/>
</FrameLayoyt>
</LinearLayout>
Your Toolbar is in the Scrollview, you can place on top of the CoordinatorLayout to solve the issue. so your code will look like this,
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<ScrollView
android:id="#+id/sc1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText />
<!-- other controls -->
</android.support.constraint.ConstraintLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
<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.