This is my layout where I want select_back relative layout to have click listener. But It's not working at all. I could not figure out the issue.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<RelativeLayout
android:id="#+id/select_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:background="#color/white"
android:clickable="true"
android:focusable="true">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:drawableStart="#drawable/left_arrow"
android:drawablePadding="10dp"
android:focusable="false"
android:fontFamily="sans-serif"
android:text="#string/village_text"
android:textColor="#color/colorPrimaryDark"
android:textSize="15sp"
android:textStyle="normal">
</androidx.appcompat.widget.AppCompatTextView>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:fillViewport="false">
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
android:layout_marginRight="20dp"
android:orientation="vertical"
android:paddingBottom="20dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:src="#drawable/village_logo" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:fontFamily="sans-serif"
android:text="#string/village_title"
android:textColor="#color/title_colr"
android:textSize="20sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:backgroundTint="#color/edittext_tint"
android:focusable="true"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_state"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/district"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_district"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_block"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/village"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:hint="#string/select_village"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal">
<requestFocus />
</androidx.appcompat.widget.AppCompatEditText>
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/speech"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="20dp"
android:adjustViewBounds="true"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:paddingBottom="5dp"
android:src="#drawable/mic" />
</RelativeLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#drawable/button_background"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:padding="10dp"
android:text="Next"
android:textColor="#color/white"
android:textSize="17sp"
android:textStyle="normal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="#string/already_account"
android:textColor="#color/textview_black"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="#string/login_text"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
This is my Onclicklistener
private RelativeLayout select_back;
select_back = findViewById(R.id.select_back);
select_back.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(RegisterActivity.this,
LanuageActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
}
});
I am trying to figure out what is wrong with it but not getting any clue. Could you please help me in figuring out the issue? this is my whole layout part.
Your scrollview overlap the relativelayout so you cannot get click event, just change the sequence and it will works.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:fillViewport="false">
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
android:layout_marginRight="20dp"
android:orientation="vertical"
android:paddingBottom="20dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:src="#drawable/village_logo" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:fontFamily="sans-serif"
android:text="#string/village_title"
android:textColor="#color/title_colr"
android:textSize="20sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:backgroundTint="#color/edittext_tint"
android:focusable="true"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_state"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/district"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_district"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_block"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/village"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:hint="#string/select_village"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal">
<requestFocus />
</androidx.appcompat.widget.AppCompatEditText>
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/speech"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="20dp"
android:adjustViewBounds="true"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:paddingBottom="5dp"
android:src="#drawable/mic" />
</RelativeLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#drawable/button_background"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:padding="10dp"
android:text="Next"
android:textColor="#color/white"
android:textSize="17sp"
android:textStyle="normal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="#string/already_account"
android:textColor="#color/textview_black"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="#string/login_text"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/select_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:background="#color/white"
android:clickable="true"
android:focusable="true">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:drawableStart="#drawable/left_arrow"
android:drawablePadding="10dp"
android:focusable="false"
android:fontFamily="sans-serif"
android:text="#string/village_text"
android:textColor="#color/colorPrimaryDark"
android:textSize="15sp"
android:textStyle="normal">
</androidx.appcompat.widget.AppCompatTextView>
</RelativeLayout>
Thats not a good thing to assign setOnClickListener into a Parent class in xml, but if you want to make it work you need to declare the private RelativeLayout select_back; as global place it on the top of protected void onCreate(Bundle savedInstanceState)
So I came to know that my scroll view layout was overlapping my Relative Layout. I put this Relative Layout inside Scrollview and now it's working like a charm.
Related
I am new to designing layouts , and i am trying to make this layout resizable with
android:windowSoftInputMode="adjustResize"
everything is working perfectly but the problem is i can't get the last relative layout to go all the way to the bottom
i tried to set gravity to bottom but it did not work
i added a line in my code where my problem occurs
here is my activity layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
tools:context=".testLayout">
<RelativeLayout
android:id="#+id/mainLayout"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/logoLayout"
>
<ImageView
android:layout_width="140dp"
android:layout_height="35dp"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:background="#drawable/nlogo">
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/logoLayout1"
android:layout_below="#id/logoLayout"
>
<EditText
android:id="#+id/testUsernameText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="50dp"
android:background="#drawable/rounded_background"
android:gravity="center_vertical"
android:hint="Username"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/white"
android:textColorHint="#color/hint_color"
android:textCursorDrawable="#null"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<EditText
android:id="#+id/testPasswordText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:background="#drawable/rounded_background"
android:gravity="center_vertical"
android:hint="Password"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/white"
android:textColorHint="#color/hint_color"
android:textCursorDrawable="#null"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<EditText
android:id="#+id/testEmailText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:background="#drawable/rounded_background"
android:gravity="center_vertical"
android:hint="Email"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/white"
android:textColorHint="#color/hint_color"
android:textCursorDrawable="#null"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<EditText
android:id="#+id/testFullNameText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:background="#drawable/rounded_background"
android:gravity="center_vertical"
android:hint="Full Name"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/white"
android:textColorHint="#color/hint_color"
android:textCursorDrawable="#null"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:text="Sign Up"
android:background="#drawable/rounded_button"
/>
</LinearLayout>
<!-- here is the problem -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/logoLayout1"
android:id="#+id/footerLayout"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:text="Welcome to ....."
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
many thanks in advance
I have tried your layout in my temporary activity and adding android:fillViewport="true" in the ScrollView worked for me.
Here is the solution:
Add this line in Manifest file for your activity
android:windowSoftInputMode="adjustResize"
I have bit modified the XML file code to make it very easy to read and less view hierarchy.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:fillViewport="true">
<LinearLayout
android:id="#+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="140dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/ic_eye"
android:contentDescription="#null" />
<EditText
android:id="#+id/testUsernameText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="50dp"
android:gravity="center_vertical"
android:hint="Username"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/colorTextWhite"
android:textColorHint="#color/colorTextBlue"
android:textCursorDrawable="#null"
android:textSize="18sp" />
<EditText
android:id="#+id/testPasswordText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:gravity="center_vertical"
android:hint="Password"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/colorTextWhite"
android:textColorHint="#color/colorTextBlue"
android:textCursorDrawable="#null"
android:textSize="18sp" />
<EditText
android:id="#+id/testEmailText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:gravity="center_vertical"
android:hint="Email"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/colorTextWhite"
android:textColorHint="#color/colorTextBlue"
android:textCursorDrawable="#null"
android:textSize="18sp" />
<EditText
android:id="#+id/testFullNameText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:gravity="center_vertical"
android:hint="Full Name"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/colorTextWhite"
android:textColorHint="#color/colorTextBlue"
android:textCursorDrawable="#null"
android:textSize="18sp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="50dp"
android:background="#drawable/shape_calendar_bg"
android:text="Sign Up" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:text="Welcome to ....."
android:textColor="#color/colorTextWhite"
android:textSize="15sp" />
</LinearLayout>
</ScrollView>
While the keyboard is open
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 know it is silly question but i used many solution which already given by stack Overflow but no one solve my problem, my question is, I want to Scroll Up the layout after clicking on last edittext because keyboard hide the EditText and i am unable to see what is typing..
Code I am using in onCreate method
scrollView=(ScrollView)findViewById(R.id.activityRoot);
addressEdt=(EditText)findViewById(R.id.profilAddress);
addressEdt.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
scrollView.fullScroll(ScrollView.FOCUS_UP);
}
});
My xml code is
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:id="#+id/activityRoot">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/colorWhite">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_marginTop="10dp"
android:id="#+id/linearLayout7">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/driverName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|bottom"
android:layout_marginTop="90dp"
android:gravity="center"
android:padding="5dp"
android:text="Kevin Michaels"
android:textSize="18dp" />
<TextView
android:id="#+id/total_rides_editProfile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|bottom"
android:layout_marginTop="140dp"
android:gravity="center"
android:padding="5dp"
android:text=""
android:textSize="17dp" />
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/userProfileImageView"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center_horizontal|top"
android:scaleType="centerCrop"
android:src="#drawable/profile_user_icon" />
<ProgressBar
android:id="#+id/profileImageProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="30dp" />
<ImageView
android:id="#+id/userChangePhotoButton"
android:layout_width="37dp"
android:layout_height="37dp"
android:layout_gravity="right|top"
android:src="#drawable/camera_icon" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:layout_below="#+id/linearLayout7">
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="center_horizontal"
android:hint="Username"
android:paddingLeft="15dp"
android:paddingRight="60dp"
android:layout_marginTop="7dp"
android:gravity="center"
android:maxLength="20"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
style="#style/ProfileUserNameEditText"
android:singleLine="true"
android:id="#+id/txtprofileUserName"/>
<EditText
style="#style/ProfileMobileNumberEditText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/profileMobile"
android:layout_gravity="center_horizontal"
android:hint="Mobile"
android:paddingLeft="15dp"
android:paddingRight="60dp"
android:layout_marginTop="7dp"
android:gravity="center"
android:maxLength="10"
android:singleLine="true"
android:inputType="phone|textPhonetic"/>
<EditText
style="#style/ProfileAddressEditText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/profilAddress"
android:layout_gravity="center_horizontal"
android:hint="Address"
android:inputType="text"
android:paddingLeft="15dp"
android:paddingRight="60dp"
android:layout_marginTop="7dp"
android:gravity="center"
android:singleLine="true"
android:maxLines="1"
android:drawableLeft="#drawable/edit_profile_address"
android:maxLength="40"
/>
<TextView
style="#style/ProfileEmailEditText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/profileEmail"
android:layout_gravity="center_horizontal"
android:hint="Email"
android:paddingLeft="15dp"
android:paddingRight="60dp"
android:layout_marginTop="7dp"
android:gravity="center"
android:singleLine="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/saveProfileButton"
android:background="#drawable/a_log_in_button"
android:text="Done"
android:textColor="#color/white"
android:layout_marginTop="10dp"
android:textSize="17dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
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"
I just put a linear layout inside a scrollview dont know why its not working.
When the keyboard is open the scrollbar is not showing at all. When i move one text box to another there is a submit button which is not show when i run on small size devices.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/layoutPopUp"
android:layout_width="match_parent"
android:layout_height="79dp"
android:background="#F57F20"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:visibility="visible">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:id="#+id/backlayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:orientation="horizontal">
<ImageButton
android:id="#+id/btnBackbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#color/transparent"
android:gravity="center"
android:src="#drawable/back"
android:visibility="visible" />
<TextView
android:id="#+id/textBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:gravity="center"
android:text="Back"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="#+id/textTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.6"
android:gravity="center"
android:text="Contact Us"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp"
android:textStyle="bold" />
<ImageButton
android:id="#+id/imagePopUp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.2"
android:background="#color/transparent"
android:gravity="center"
android:src="#drawable/menu"
android:visibility="visible" />
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black">
<requestFocus />
</EditText>
<EditText
android:id="#+id/editPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="Phone No."
android:inputType="phone"
android:maxLength="12"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<EditText
android:id="#+id/editComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:gravity="start"
android:hint="Comments"
android:inputType="textMultiLine"
android:lines="3"
android:maxLength="500"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_shape"
android:text="SUBMIT"
android:textColor="#color/white" />
</LinearLayout>
</ScrollView>
</LinearLayout>
try to put scrollview inside another linear layout and try
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/parentLin"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="//define in dp"
android:scrollbars="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:textColorHint="#2b2b2b"
android:textColor="#2b2b2b"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium">
<requestFocus />
</EditText>
<EditText
android:id="#+id/editPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:textColor="#2b2b2b"
android:hint="Phone No."
android:inputType="phone"
android:textColorHint="#2b2b2b"
android:maxLength="12"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:textColor="#2b2b2b"
android:ems="10"
android:textColorHint="#2b2b2b"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:gravity="start"
android:textColor="#2b2b2b"
android:hint="Comments"
android:textColorHint="#2b2b2b"
android:inputType="textMultiLine"
android:lines="3"
android:maxLength="500"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_shape"
android:text="SUBMIT"
android:textColor="#color/white" />
</RelativeLayout>
</RelativeLayout>
and You have to specify the following line of code in the manifest file with your activity
android:windowSoftInputMode="adjustResize"
try This.. on your activity / fragment
getActivity().getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE |
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);