This is my XML file for presenting the Layout.
edit_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/login_bg">
<LinearLayout
android:id="#+id/ll_userregisteration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="30dp"
android:isScrollContainer="true"
android:gravity="center"
android:orientation="vertical">
<RelativeLayout
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<com.shout.networking.view.RoundedImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="center"
android:src="#drawable/profile_placeholder"/>
<ImageButton
android:id="#+id/camera"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="What do we call you"
android:textColor="#color/white"
android:textSize="18sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/et_reg_Fname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:textSize="16sp"
android:layout_weight="1"
android:backgroundTint="#color/white"
android:hint="first name"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<EditText
android:id="#+id/et_reg_Lname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:textSize="16sp"
android:backgroundTint="#color/white"
android:hint="last name"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
</LinearLayout>
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/rb_male"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="true"
android:drawableLeft="#drawable/selector_radio_button"
android:drawablePadding="10dp"
android:text="Male"
android:textColor="#android:color/white"
android:textSize="18sp" />
<RadioButton
android:id="#+id/rb_female"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="false"
android:drawableLeft="#drawable/selector_radio_button"
android:drawablePadding="10dp"
android:text="Female"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RadioGroup>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="School of your cool"
android:textColor="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_university"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:textSize="14sp"
android:hint="add your university"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="what you call home"
android:textColor="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_livingaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:hint="Where do you live now"
android:textColor="#color/white"
android:textSize="16sp"
android:textColorHint="#7c7875" />
<EditText
android:id="#+id/et_permanentaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:hint="Where do you belong to"
android:textSize="16sp"
android:textColor="#color/white"
android:textColorHint="#7c7875" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Whats Your Calling"
android:textColor="#color/white"
android:textSize="18sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_interset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/white"
android:layout_toLeftOf="#+id/sp_interset"
android:hint="Type in your calling/pick from the list"
android:textSize="16sp"
android:maxLength="30"
android:textColor="#color/white"
android:textColorHint="#7c7875"
android:maxLines="1" />
<Spinner
android:id="#+id/sp_interset"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:background="#drawable/down_thicker"
android:dropDownWidth="250dp"
android:backgroundTint="#android:color/white"
android:popupBackground="#4b4b49"
android:spinnerMode="dropdown" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_marginTop="10dp">
<Button
android:id="#+id/btn_cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/selector_signup_button"
android:text="CANCEL"
android:layout_marginRight="20dp"
android:textColor="#color/black"
android:layout_weight="1"
android:textSize="15sp" />
<Button
android:id="#+id/btn_save"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/selector_signup_button"
android:text="SAVE"
android:textColor="#color/black"
android:layout_weight="1"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
This is the screenshot for my Layout.I am not able to scroll it.
I have put my Linear LAyout in the ScrollView but then also i am unable to get the scroll functionality in my xml design .
make changes in LinearLayout height to match_parent. it will work.
In ScrollView try adding this line:
app:layout_behavior="#string/appbar_scrolling_view_behavior"
Related
My app's button positions changes on different devices. Sometimes buttons are getting bigger, sometimes getting smaller,sometimes a part of buttons arent visible. I use vertical linear layout. Buttons are in drawable folder and button sizes are 227x231 px.
There are some sample screenshots. Pixel 2 - Pixel 3a - Mi 9T Pro
How can i fix ?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back4">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="95dp"
android:background="#drawable/a"
android:orientation="horizontal">
<TextView
android:id="#+id/teamName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:fontFamily="#font/andika"
android:paddingTop="20dp"
android:text="Team 1"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="20sp" />
<TextView
android:id="#+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:paddingLeft="50dp"
android:text="5"
android:textColor="#303f9f"
android:textSize="36sp"
android:textStyle="bold" />
<TextView
android:id="#+id/roundText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:fontFamily="#font/andika"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:text="Round 1/5"
android:textAlignment="viewStart"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
<TextView
android:id="#+id/timeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="20dp"
android:layout_marginRight="100dp"
android:fontFamily="#font/arsenal_bold"
android:text="60"
android:textAlignment="center"
android:textColor="#E2DADA"
android:textSize="40sp"
android:textStyle="bold" />
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="0"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="419dp"
android:background="#drawable/game4"
android:orientation="vertical">
<TextView
android:id="#+id/guessWord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="80dp"
android:text="Guess "
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="38sp"
android:textStyle="bold" />
<TextView
android:id="#+id/translateWord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="80dp"
android:text="(Translate)"
android:textAlignment="center"
android:textColor="#D0FFFFFF"
android:textSize="26sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tabuWord1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginTop="35dp"
android:layout_marginEnd="80dp"
android:text="TextView"
android:textAlignment="center"
android:textSize="30sp" />
<TextView
android:id="#+id/tabuWord2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="80dp"
android:text="TextView"
android:textAlignment="center"
android:textSize="30sp" />
<TextView
android:id="#+id/tabuWord3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="80dp"
android:text="TextView"
android:textAlignment="center"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="123dp"
android:orientation="horizontal">
<Button
android:id="#+id/tabuButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="30dp"
android:layout_weight="1"
android:background="#drawable/tabubutton2" />
<Button
android:id="#+id/passButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="30dp"
android:layout_weight="1"
android:background="#drawable/pasbutton2" />
<Button
android:id="#+id/trueButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="30dp"
android:layout_weight="1"
android:background="#drawable/truebutton2" />
</LinearLayout>
</LinearLayout>
You should use ScrollView but if you don't want the screen scrolling you should rebuild it using ConstraintLayout
You can do it with something like this:
<?xml version="1.0" encoding="utf-8"?>
<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">
<ScrollView
style="#style/parent"
tools:ignore="MissingConstraints">
.......
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
style.xml
<style name="parent">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
I think this should work on all screens
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back4">
<ScrollView
style="#style/parent"
tools:ignore="MissingConstraints,ScrollViewCount">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="95dp"
android:background="#drawable/a"
android:orientation="horizontal">
<TextView
android:id="#+id/teamName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:fontFamily="#font/andika"
android:paddingTop="20dp"
android:text="Team 1"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="20sp" />
<TextView
android:id="#+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:paddingLeft="50dp"
android:text="5"
android:textColor="#303f9f"
android:textSize="36sp"
android:textStyle="bold" />
<TextView
android:id="#+id/roundText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:fontFamily="#font/andika"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:text="Round 1/5"
android:textAlignment="viewStart"
android:textColor="#000000"
android:textSize="20sp" />
</LinearLayout>
<TextView
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/timeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/arsenal_bold"
android:text="60"
android:textAlignment="center"
android:textColor="#E2DADA"
android:textSize="40sp"
android:textStyle="bold" />
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="0"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/game4"
android:orientation="vertical">
<TextView
android:layout_margin="25dp"
android:id="#+id/guessWord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Guess "
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="38sp"
android:textStyle="bold" />
<TextView
android:layout_margin="15dp"
android:id="#+id/translateWord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="(Translate)"
android:textAlignment="center"
android:textColor="#D0FFFFFF"
android:textSize="26sp"
android:textStyle="bold" />
<TextView
android:layout_margin="15dp"
android:id="#+id/tabuWord1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textAlignment="center"
android:textSize="30sp" />
<TextView
android:layout_margin="15dp"
android:id="#+id/tabuWord2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textAlignment="center"
android:textSize="30sp" />
<TextView
android:layout_margin="15dp"
android:id="#+id/tabuWord3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textAlignment="center"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_margin="25dp"
android:id="#+id/tabuButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/tabubutton2" />
<Button
android:layout_margin="25dp"
android:id="#+id/passButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/pasbutton2" />
<Button
android:layout_margin="25dp"
android:id="#+id/trueButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/truebutton2" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
I want to put a scrollView between two Layout and put all 3 layout in 1 constraintLayout as below :
<ConstraintLayout>
<LinearLayout> // Title
<ScrollView>
<RelativeLayout> // Buttons
<ConstraintLayout>
this in my Layout XML code :
<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:id="#+id/registerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
app:layout_constraintRight_toRightOf="parent"
tools:context="momtaz.moshaver_yar.StudentFragment_Register">
<LinearLayout
android:id="#+id/titleLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#color/colorPrimary"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/registerStudentTitleTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="ثبت نام دانش آموز"
android:textColor="#color/colorPrimaryText"
android:textSize="20sp" />
</LinearLayout>
<ScrollView
android:id="#+id/registerStudentScroll"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#android:color/white"
android:fillViewport="true"
android:orientation="vertical"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="#+id/registerStudentBtn"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/titleLayout">
<LinearLayout
android:id="#+id/regstscrollayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerNameLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStNameEdit"
android:text="نام و نام خانوادگی :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStNameEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="right|center_vertical"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerBirthDateLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="تاریخ تولد :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<TextView
android:id="#+id/registerBirthDateTxt"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center"
android:textColor="#android:color/black"
android:textDirection="rtl"
android:textSize="14sp"
tools:text="10/08/1369" />
<Button
android:id="#+id/registerBirthDateBtn"
android:layout_width="28dp"
android:layout_height="28dp"
android:background="#drawable/datebtnselector" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerGenderLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="جنسیت :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="#+id/registerGenderBoy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/radiobtnselector"
android:paddingLeft="5dp"
android:text=" پسر"
android:textColor="#android:color/black"
android:textSize="16sp" />
<RadioButton
android:id="#+id/registerGenderGirl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/radiobtnselector"
android:text=" دختر"
android:textColor="#android:color/black"
android:textSize="16sp" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerMCodeLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="کد ملی :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStMCodeEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerMobileLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#+id/regStPhoneEdit"
android:text="شماره تماس :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStMobileEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="phone"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerPhoneLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="شماره تماس منزل :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStPhoneEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="phone"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerStGradeLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="پایه تحصیلی :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStGradeEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="phone"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TableRow
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerAdviserLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStAdviserEdit"
android:text="کد مشاور :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<AutoCompleteTextView
android:id="#+id/regStAdviserEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerAdviserNameLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStNameEdit"
android:text="نام مشاور :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<TextView
android:id="#+id/regStAdviserNameTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#android:color/black"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TableRow
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerStUNameLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStUNameEdit"
android:text="نام کاربری :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStUNameEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerStUPassLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStUPassEdit"
android:text="رمز عبور :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStUPassEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerStUPass2Label"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStUPass2Edit"
android:text="تکرار رمز عبور :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStUPass2Edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/registerStudentBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<Button
android:id="#+id/regStPostBtn"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="5dp"
android:background="#drawable/btnselector"
android:text="ثبت"
android:textColor="#android:color/white"
android:textSize="16sp" />
<ImageView
android:id="#+id/regStProgressImg"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toLeftOf="#+id/regStPostBtn"
android:background="#drawable/loading_animate" />
<Button
android:id="#+id/regStCancelBtn"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:background="#drawable/btnselector"
android:text="انصراف"
android:textColor="#android:color/white"
android:textSize="16sp" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
I have created this connections of constraintLayout :
Top of TitleLayout to Top of Parent
Top of ScrollView to Bottom of TitleLayout
Bottom of ScrollView to Top of ButtonLayout
Bottom of ButtonLayout to Bottom of Parent
Right and Left of All Layouts to Right and Left of Parent
There is no problem is Design-View but when I test it in GenyMotion emulator, the ButtonLayout doesn't show, it seems that the Height of ScrollView is larger than the space between bottom of TitleView and top of ButtonLayout, I can't find out whats going wrong !
I have tested NestedScrollView instead of ScrollView or RelativeLayout instead of ConstraintLayout but the problem not solved
I suggest you put the LinearLayout, ScrollView and the RelativeLayout in a vertical chain to keep them properly constrained to each other and to prevent them from overlapping. In order to create the chain you need to add a couple additional constraints:
bottom of TitleLayout to top of ScrollView
top of ButtonLayout to bottom of ScrollView
Please note that I only added two additional constraints to create a chain and did not change anything else or did not fix any other small problems with the XML:
<?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:id="#+id/registerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
app:layout_constraintRight_toRightOf="parent"
tools:context="momtaz.moshaver_yar.StudentFragment_Register">
<LinearLayout
android:id="#+id/titleLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#color/colorPrimary"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#id/registerStudentScroll"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/registerStudentTitleTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="ثبت نام دانش آموز"
android:textColor="#color/colorPrimaryText"
android:textSize="20sp" />
</LinearLayout>
<ScrollView
android:id="#+id/registerStudentScroll"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#android:color/white"
android:fillViewport="true"
android:orientation="vertical"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="#+id/registerStudentBtn"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/titleLayout">
<LinearLayout
android:id="#+id/regstscrollayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerNameLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStNameEdit"
android:text="نام و نام خانوادگی :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStNameEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="right|center_vertical"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerBirthDateLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="تاریخ تولد :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<TextView
android:id="#+id/registerBirthDateTxt"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center"
android:textColor="#android:color/black"
android:textDirection="rtl"
android:textSize="14sp"
tools:text="10/08/1369" />
<Button
android:id="#+id/registerBirthDateBtn"
android:layout_width="28dp"
android:layout_height="28dp"
android:background="#drawable/datebtnselector" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerGenderLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="جنسیت :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="#+id/registerGenderBoy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/radiobtnselector"
android:paddingLeft="5dp"
android:text=" پسر"
android:textColor="#android:color/black"
android:textSize="16sp" />
<RadioButton
android:id="#+id/registerGenderGirl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/radiobtnselector"
android:text=" دختر"
android:textColor="#android:color/black"
android:textSize="16sp" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerMCodeLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="کد ملی :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStMCodeEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerMobileLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#+id/regStPhoneEdit"
android:text="شماره تماس :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStMobileEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="phone"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerPhoneLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="شماره تماس منزل :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStPhoneEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="phone"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerStGradeLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:text="پایه تحصیلی :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStGradeEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="phone"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TableRow
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerAdviserLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStAdviserEdit"
android:text="کد مشاور :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<AutoCompleteTextView
android:id="#+id/regStAdviserEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerAdviserNameLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStNameEdit"
android:text="نام مشاور :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<TextView
android:id="#+id/regStAdviserNameTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#android:color/black"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TableRow
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerStUNameLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStUNameEdit"
android:text="نام کاربری :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStUNameEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerStUPassLabel"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStUPassEdit"
android:text="رمز عبور :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStUPassEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/registerStUPass2Label"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="left"
android:labelFor="#id/regStUPass2Edit"
android:text="تکرار رمز عبور :"
android:textColor="#android:color/black"
android:textSize="15sp" />
<EditText
android:id="#+id/regStUPass2Edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/editselector"
android:gravity="left|center_vertical"
android:inputType="number"
android:padding="3dp"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/registerStudentBtn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#id/registerStudentScroll"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<Button
android:id="#+id/regStPostBtn"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="5dp"
android:background="#drawable/btnselector"
android:text="ثبت"
android:textColor="#android:color/white"
android:textSize="16sp" />
<ImageView
android:id="#+id/regStProgressImg"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toLeftOf="#+id/regStPostBtn"
android:background="#drawable/loading_animate" />
<Button
android:id="#+id/regStCancelBtn"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:background="#drawable/btnselector"
android:text="انصراف"
android:textColor="#android:color/white"
android:textSize="16sp" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
I need to align the images and buttons equall with the header but it's not assigning. When I check in landscape, align getting mismatch. Here is my code.
When I checked in device, it's not fitting correctly.
Below is the code and output screen (My output and actual output which needed).
I used weight but it's not fitting correctly in all devices.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorAlabaster">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="50dp"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="Pindahkan ke hari" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="1">
<com.hutchison.h3i.newangie.customviews.CircleImageView
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_number"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_very_small" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_name"
android:textColor="#color/colorCyan"
android:textSize="#dimen/text_size_very_small" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_marginLeft="8dp"
android:background="#drawable/border_grey_curve"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".2">
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#drawable/ic_arrow_right"
android:gravity="center"
android:textColor="#color/colorBlack"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:background="#drawable/border_grey_curve"
android:drawablePadding="5dp"
android:drawableRight="#drawable/ic_arrow_bottom"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_small" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
My Output:
Actual output:
Here i have fixed the issue for you. But as the screen size will increase so does the size between your button and upper portion too. But your layout won't get messy. And if you want everything to remain fixed even on bigger screen sizes then you should use constraintLayout.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryLight">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="50dp"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="Pindahkan ke hari" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:weightSum="4">
<com.hutchison.h3i.newangie.customviews.CircleImageView
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="sad234 234234"
android:textColor="#color/primary_text"
android:textSize="12sp" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/title_activity_test"
android:textColor="#color/secondary_text"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1.5">
<android.support.v7.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dp"
android:background="#drawable/bg_spinner_nothing_selected"
android:gravity="center"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/primary_text" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight=".5">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#drawable/ic_add"
android:gravity="center"
android:textColor="#color/primary_text"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1.5">
<android.support.v7.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#drawable/bg_spinner_nothing_selected"
android:drawableRight="#drawable/ic_edit_grey"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/primary_text"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Hope it will help you. I have replaced the colors and ic_images with mine you will have to change them too by your own.
Hope this would work. I redesign with your same xml file.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorAlabaster">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="0dp"
android:layout_weight=".2"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Pindahkan ke hari" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="1">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<com.hutchison.h3i.newangie.customviews.CircleImageViewx
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_number"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_very_small" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_name"
android:textColor="#color/colorCyan"
android:textSize="#dimen/text_size_very_small" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#drawable/border_grey_curve"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_weight=".2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:background="#drawable/ic_arrow_right"
android:gravity="center"
android:textColor="#color/colorBlack"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:background="#drawable/border_grey_curve"
android:drawablePadding="5dp"
android:drawableRight="#drawable/ic_arrow_bottom"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_small" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
My question may be [duplicate] i try all solutions but nothing work.
Activity declare in manifest
I am using adjustResize but its not work . i try adjustPan and other option but no one works.
<activity
android:name=".NotesActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"></activity>
XML screen code
I am using scroll view but still cant prevent screen blockage .
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:fitsSystemWindows="false"
android:focusable="true"
android:focusableInTouchMode="true">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:theme="#style/AppTheme">
<TextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#color/colorwhite"
android:textSize="18sp" />
</android.support.v7.widget.Toolbar>
<View
android:id="#+id/sep"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/toolbar"
android:background="#color/colorwhite" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/sep"
android:background="#color/colorPrimaryDark"
android:fillViewport="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="15dp"
android:scrollbars="none">
<LinearLayout
android:id="#+id/llayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Medical Certificate Issued:"
android:textColor="#color/colorwhite"
android:textSize="16sp" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/round_edittext"
android:orientation="horizontal"
android:padding="8dp"
android:theme="#style/AppTheme3">
<RadioButton
android:id="#+id/radio_yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:buttonTint="#color/colorblack"
android:onClick="onRadioButtonClicked"
android:paddingRight="10dp"
android:text="Yes"
android:textSize="18sp"
android:theme="#style/AppTheme3" />
<RadioButton
android:id="#+id/radio_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:buttonTint="#color/colorblack"
android:checked="true"
android:onClick="onRadioButtonClicked"
android:text="No"
android:textSize="18sp"
android:theme="#style/AppTheme3" />
</RadioGroup>
<LinearLayout
android:id="#+id/certificate_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:padding="25dp"
android:weightSum="2">
<TextView
android:id="#+id/certificate_from"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:gravity="center_vertical|left"
android:maxLines="1"
android:minLines="1"
android:paddingBottom="8dp"
android:paddingLeft="5dp"
android:paddingTop="8dp"
android:text="From"
android:textColor="#color/colorblack" />
<TextView
android:id="#+id/certificate_to"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:gravity="center_vertical|left"
android:maxLines="1"
android:minLines="1"
android:paddingBottom="8dp"
android:paddingLeft="5dp"
android:paddingTop="8dp"
android:text="To"
android:textColor="#color/colorblack" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Follow up required:"
android:textColor="#color/colorwhite"
android:textSize="16sp" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/round_edittext"
android:orientation="horizontal"
android:padding="8dp"
android:theme="#style/AppTheme3">
<RadioButton
android:id="#+id/radio_follow_yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:buttonTint="#color/colorblack"
android:paddingRight="10dp"
android:text="Yes"
android:textSize="18sp"
android:theme="#style/AppTheme3" />
<RadioButton
android:id="#+id/radio_follow_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:buttonTint="#color/colorblack"
android:checked="true"
android:text="No"
android:textSize="18sp"
android:theme="#style/AppTheme3" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/round_edittext"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:weightSum="3">
<CheckBox
android:id="#+id/checkbox_sc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_weight="1.1"
android:buttonTint="#color/colorblack"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="SC"
android:theme="#style/AppTheme3" />
<CheckBox
android:id="#+id/checkbox_p"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_weight="1.1"
android:buttonTint="#color/colorblack"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="P"
android:theme="#style/AppTheme3" />
<CheckBox
android:id="#+id/checkbox_pt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="0.8"
android:buttonTint="#color/colorblack"
android:ems="3"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="PT"
android:theme="#style/AppTheme3" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/round_edittext"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:weightSum="3">
<CheckBox
android:id="#+id/checkbox_rfb"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_weight="1.1"
android:buttonTint="#color/colorblack"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="RFB"
android:theme="#style/AppTheme3" />
<CheckBox
android:id="#+id/checkbox_path"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_weight="1.1"
android:buttonTint="#color/colorblack"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="PATH"
android:theme="#style/AppTheme3" />
<CheckBox
android:id="#+id/checkbox_ref"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="0.8"
android:buttonTint="#color/colorblack"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="REF"
android:theme="#style/AppTheme3" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/edit"
android:text="Your Signature:"
android:textColor="#color/colorwhite"
android:textSize="16sp" />
<TextView
android:id="#+id/remove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:background="#drawable/round_line"
android:ems="5"
android:gravity="center"
android:maxLines="1"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="8dp"
android:text="Remove"
android:textColor="#color/colorwhite" />
<TextView
android:id="#+id/edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/remove"
android:background="#drawable/round_line"
android:ems="5"
android:gravity="center"
android:maxLines="1"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="8dp"
android:text="Edit"
android:textColor="#color/colorwhite" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/round_edittext">
<TextView
android:id="#+id/add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:minLines="7"
android:text="Add your signature!"
android:textColor="#color/colorblack"
android:textSize="20sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/signature_img"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_alignBottom="#+id/add"
android:layout_alignLeft="#+id/add"
android:layout_alignRight="#+id/add"
android:layout_alignTop="#+id/add" />
</RelativeLayout>
<Button
android:id="#+id/submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/round_green"
android:gravity="center"
android:maxLines="1"
android:paddingBottom="8dp"
android:paddingLeft="5dp"
android:paddingTop="8dp"
android:text="Submit"
android:textColor="#color/colorwhite"
android:textSize="18sp" />
</LinearLayout>
</ScrollView>
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="8dp"
android:visibility="gone" />
Try adding alignParentBottom to your ScrollView. So when your parent will be stretched, the ScrollView will follow and be stretched as well. Let me know if that works!
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/sep"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimaryDark"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="15dp"
android:scrollbars="none">
i use just
android:windowSoftInputMode="stateHidden|adjustResize"
and it works in my applications
In my application i am using recycler view and scrollview in one layout. it is not working when i am using both these views. If i remove scroll view only the recycler view is working. Plese any one help me hoe to fix this issue.
my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/r1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
>
<ScrollView
android:id="#+id/sc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1e356a">
<TextView
android:id="#+id/placce_head"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Hyderabad to banglore"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:weightSum="2"
android:orientation="horizontal">
<TextView
android:id="#+id/seats"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="Selected Seats"
android:textColor="#ffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/totalamount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="Total Amount"
android:textColor="#ffffff"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:weightSum="2"
android:orientation="horizontal">
<TextView
android:id="#+id/seat_num"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:textColor="#ffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/total_amount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#ffffff"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/boardingpoint_edttxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint=" Select Boarding Point"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/contact_details"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Contact Details"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
<EditText
android:id="#+id/contactname_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Contact Name"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/email_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Email Address"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/contactnum_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Contact Number"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<EditText
android:id="#+id/emergency_edt_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="22dp"
android:background="#null"
android:hint="Emergency Contact Number"
android:textColorHint="#1e365a"
android:textSize="15dp" />
<View
android:layout_width="fill_parent"
android:layout_height="0.8dp"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="7dp"
android:background="#1e365a" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#78869c"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/passenger_details"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Passenger Details"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/view"
android:layout_below="#+id/sc"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<LinearLayout
android:id="#+id/coupon_lay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="8dp"
android:layout_marginTop="12dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:weightSum="100" >
<EditText
android:id="#+id/entercouponcode_edt"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="50"
android:hint="Enter coupn code"
android:inputType="text" >
<requestFocus />
</EditText>
<Button
android:id="#+id/bt_apply"
style="#style/payment_button_style"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="-5dp"
android:layout_weight="40"
android:gravity="center"
android:text="Apply" />
</LinearLayout>
<Button
android:id="#+id/pay_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="28dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:background="#F93249"
android:duplicateParentState="true"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="Proceed to Pay"
android:textColor="#ffffff"
android:textSize="20dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
you must know that ,your scrollview property is set as MatchParent ,which means it will fill the content view, so i suggest to set Height a real value such as 100dp, and it will work
You need to dynamically change the height of the recyclerview, depending on how many items you have.
int recyclerheight = height_per_item * adapterData.size();
recyclerView.getLayoutParams().height = recyclerheight;
The scroll view blocks the recyclerview from changing its height set in the xml, that's why you need to do it programically.