How to put this imageView in this place? - Android - android

I've got a problem with adding logo to my app.
Now it's like:
HERE IS A LOGO - CLICK (haven't got 10 reputation)
I want to have a imageview with logo (id: logo) above the box with login.
How to make it?
Layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:facebook="http://schemas.android.com/tools"
xmlns:fb="http://schemas.android.com/tools"
android:id="#+id/mainView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#drawable/log"
android:gravity="center"
android:orientation="vertical">
<ScrollView
android:background="#drawable/log"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<RelativeLayout
android:background="#drawable/login"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="350dp"
android:layout_marginLeft="17dp"
android:layout_height="300dp"
android:layout_marginTop="120dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
app:srcCompat="#drawable/napis"
android:id="#+id/logosek" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/social_signin_layout"
android:layout_marginTop="10dp"
android:background="#color/md_white_1000"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="#+id/tv_or"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:text="#string/screen_login_or_label"
android:textColor="#color/md_black_1000"
android:textSize="24sp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:textColorHint="#color/material_color_primary"
app:hintAnimationEnabled="true"
app:hintTextAppearance="#style/TextAppearance.AppCompat.Small">
<EditText
android:id="#+id/et_usernamelogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/screen_register_hint_email"
android:inputType="text"
android:singleLine="true"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<!--<EditText-->
<!--android:id="#+id/"-->
<!--style="#style/edittextstyle"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="#dimen/editlayimg_edittextheight"-->
<!--android:layout_marginTop="#dimen/five"-->
<!--android:gravity="bottom"-->
<!--android:hint="#string/login_storeid"-->
<!--android:singleLine="true"-->
<!--android:textColorHint="#color/fontcolorlight"-->
<!--android:textSize="18sp" />-->
<!--<View-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="#dimen/one"-->
<!--android:layout_marginLeft="#dimen/five"-->
<!--android:layout_marginRight="#dimen/five"-->
<!--android:background="#color/fontcolorlight" />-->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:textColorHint="#color/material_color_primary"
app:hintAnimationEnabled="true"
app:hintTextAppearance="#style/TextAppearance.AppCompat.Small">
<EditText
android:id="#+id/et_passwordlogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="text"
android:singleLine="true"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btn_login"
style="#style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="match_parent"
android:layout_height="#dimen/btnheight"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="4dp"
android:background="#color/material_color_accent"
android:text="#string/screen_login_button_login"
android:textColor="#color/md_white_1000"
android:textSize="#dimen/btnlogin_textsize" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="4dp"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/txt_signup"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:gravity="left"
android:paddingLeft="8dp"
android:text="#string/screen_login_button_sign_up"
android:textColor="#color/md_black_1000"
android:textSize="16sp"
android:layout_width="wrap_content" />
<TextView
android:id="#+id/tv_forgotpwd"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:gravity="right"
android:paddingRight="8dp"
android:text="Forgot Password?"
android:textColor="#color/md_black_1000"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_above"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/md_brown_100"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</LinearLayout>
<LinearLayout
android:id="#+id/social_signin_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="100dp"
android:layout_below="#+id/lay_above"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="Choose account to login"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textColor="#color/md_yellow_50"
android:textAlignment="center"
android:textSize="17sp" />
<com.google.android.gms.common.SignInButton
android:id="#+id/btn_sign_in"
android:layout_width="300dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="16dp"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginRight="16dp"
android:padding="0dp"
android:theme="#style/Widget.AppCompat.Button"
app:theme="#style/Widget.AppCompat.Button"
android:layout_height="35dp"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="or"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textColor="#color/AntiqueWhite"
android:textAlignment="center"
android:textSize="18sp"
android:id="#+id/textView10" />
<com.facebook.login.widget.LoginButton
android:id="#+id/authButton"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="10dp"
android:textSize="18sp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_width="300dp"
android:layout_height="50dp" />
<TextView
android:layout_width="match_parent"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="#string/please_login_in"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textColor="#color/md_yellow_50"
android:textAlignment="center"
android:textSize="15sp"
android:id="#+id/textView12" />
</LinearLayout>
<TextView
android:text="Welcome, Saiyan!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:id="#+id/textView14"
android:textSize="36sp"
android:layout_below="#+id/lay_above"
android:layout_centerHorizontal="true"
android:textColor="#color/Yellow" />
</RelativeLayout>
</ScrollView>
</LinearLayout>

just put the imageview before the relative layout
instead of:
<RelativeLayout
android:background="#drawable/login"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="350dp"
android:layout_marginLeft="17dp"
android:layout_height="300dp"
android:layout_marginTop="120dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
app:srcCompat="#drawable/napis"
android:id="#+id/logosek" />
do:
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
app:srcCompat="#drawable/napis"
android:id="#+id/logosek" />
<RelativeLayout
android:background="#drawable/login"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="350dp"
android:layout_marginLeft="17dp"
android:layout_height="300dp"
android:layout_marginTop="120dp">
this will put imageview in the scrollview and below it the rest of the relativelayout , all because of the linearlayout orientation which directed vertical , so every child will come below the former.
EDIT :
you also need to put the scrollview first and then put the linearlayout , this should be it :
<?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:facebook="http://schemas.android.com/tools"
xmlns:fb="http://schemas.android.com/tools"
android:background="#drawable/log"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<LinearLayout
android:id="#+id/mainView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#drawable/log"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
app:srcCompat="#drawable/napis"
android:id="#+id/logosek" />
<RelativeLayout
android:background="#drawable/login"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="350dp"
android:layout_marginLeft="17dp"
android:layout_height="300dp"
android:layout_marginTop="120dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/social_signin_layout"
android:layout_marginTop="10dp"
android:background="#color/md_white_1000"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="#+id/tv_or"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:text="#string/screen_login_or_label"
android:textColor="#color/md_black_1000"
android:textSize="24sp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:textColorHint="#color/material_color_primary"
app:hintAnimationEnabled="true"
app:hintTextAppearance="#style/TextAppearance.AppCompat.Small">
<EditText
android:id="#+id/et_usernamelogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/screen_register_hint_email"
android:inputType="text"
android:singleLine="true"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<!--<EditText-->
<!--android:id="#+id/"-->
<!--style="#style/edittextstyle"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="#dimen/editlayimg_edittextheight"-->
<!--android:layout_marginTop="#dimen/five"-->
<!--android:gravity="bottom"-->
<!--android:hint="#string/login_storeid"-->
<!--android:singleLine="true"-->
<!--android:textColorHint="#color/fontcolorlight"-->
<!--android:textSize="18sp" />-->
<!--<View-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="#dimen/one"-->
<!--android:layout_marginLeft="#dimen/five"-->
<!--android:layout_marginRight="#dimen/five"-->
<!--android:background="#color/fontcolorlight" />-->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:textColorHint="#color/material_color_primary"
app:hintAnimationEnabled="true"
app:hintTextAppearance="#style/TextAppearance.AppCompat.Small">
<EditText
android:id="#+id/et_passwordlogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="text"
android:singleLine="true"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btn_login"
style="#style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="match_parent"
android:layout_height="#dimen/btnheight"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="4dp"
android:background="#color/material_color_accent"
android:text="#string/screen_login_button_login"
android:textColor="#color/md_white_1000"
android:textSize="#dimen/btnlogin_textsize" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="4dp"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/txt_signup"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:gravity="left"
android:paddingLeft="8dp"
android:text="#string/screen_login_button_sign_up"
android:textColor="#color/md_black_1000"
android:textSize="16sp"
android:layout_width="wrap_content" />
<TextView
android:id="#+id/tv_forgotpwd"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:gravity="right"
android:paddingRight="8dp"
android:text="Forgot Password?"
android:textColor="#color/md_black_1000"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_above"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/md_brown_100"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</LinearLayout>
<LinearLayout
android:id="#+id/social_signin_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="100dp"
android:layout_below="#+id/lay_above"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="Choose account to login"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textColor="#color/md_yellow_50"
android:textAlignment="center"
android:textSize="17sp" />
<com.google.android.gms.common.SignInButton
android:id="#+id/btn_sign_in"
android:layout_width="300dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="16dp"
android:layout_gravity="center_vertical|center_horizontal"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginRight="16dp"
android:padding="0dp"
android:theme="#style/Widget.AppCompat.Button"
app:theme="#style/Widget.AppCompat.Button"
android:layout_height="35dp"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="or"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textColor="#color/AntiqueWhite"
android:textAlignment="center"
android:textSize="18sp"
android:id="#+id/textView10" />
<com.facebook.login.widget.LoginButton
android:id="#+id/authButton"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="10dp"
android:textSize="18sp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_width="300dp"
android:layout_height="50dp" />
<TextView
android:layout_width="match_parent"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="#string/please_login_in"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textColor="#color/md_yellow_50"
android:textAlignment="center"
android:textSize="15sp"
android:id="#+id/textView12" />
</LinearLayout>
<TextView
android:text="Welcome, Saiyan!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:id="#+id/textView14"
android:textSize="36sp"
android:layout_below="#+id/lay_above"
android:layout_centerHorizontal="true"
android:textColor="#color/Yellow" />
</RelativeLayout>
</LinearLayout>
</ScrollView>

Related

Recycler view items auto wrapping inside scrollview

I am a newbie to android. I have Recyclerview implemented inside NestedScrollView. When I press next everything works fine, but when I return to the previous item it just wraps itself.
I have tried everything possible to make it work.
Following is the code.
For the Next & previous question, on pressing respective the following code executes
QuizAttemptFragment.xml.
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fillViewport="true"
tools:context=".view.fragments.QuizAttemptFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:descendantFocusability="beforeDescendants"
android:layout_width="match_parent"
android:id="#+id/clQuiz"
android:layout_height="match_parent">
<TextView
android:id="#+id/tvFeedBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="15dp"
android:fontFamily="#font/nunito_regular"
tools:text="Feedback"
android:gravity="center"
android:drawablePadding="4dp"
android:drawableStart="#drawable/ic_comment_black"
android:drawableTint="#color/blackColor"
android:textSize="14sp"
android:visibility="visible"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/tvAssignmentStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginTop="15dp"
android:fontFamily="#font/nunito_regular"
tools:text="Marked"
android:textSize="14sp"
android:textAllCaps="true"
android:visibility="invisible"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvQuestionNum"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="47dp"
android:layout_marginEnd="16dp"
android:nestedScrollingEnabled="false"
android:orientation="horizontal"
tools:listitem="#layout/layout_num"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvQuestionDet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:visibility="gone"
android:layout_marginEnd="16dp"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="#+id/pbFragmentListLoading"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="56dp"
android:visibility="gone"
android:indeterminate="true"
android:indeterminateTint="#color/yellowThemeColor"
android:indeterminateTintMode="src_atop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.526"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tvDur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="93dp"
android:drawableStart="#drawable/ic_clock_blck"
android:drawablePadding="10dp"
android:fontFamily="#font/nunito_bold"
android:gravity="center_vertical"
android:text="DD:HH:MM"
android:textColor="#000000"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.089"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteY="98dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvQuestionNew"
android:nestedScrollingEnabled="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:minHeight="300dp"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="#id/rlNav"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvDur"
app:layout_constraintVertical_bias="0.0"
tools:listitem="#layout/user_question" />
<RelativeLayout
android:id="#+id/rlNav"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_marginBottom="24dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="#+id/tvBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:layout_alignParentStart="true"
android:drawablePadding="10dp"
android:drawableTint="#color/blackColor"
android:fontFamily="#font/nunito_regular"
android:gravity="center"
android:textAllCaps="true"
android:text="Previous"
android:textColor="#color/blackColor"
android:textSize="16sp"
android:visibility="invisible" />
<ImageButton
android:background="#android:color/transparent"
android:id="#+id/ibFlag"
android:visibility="visible"
android:layout_centerInParent="true"
android:src="#drawable/ic_flag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/tvNext"
android:layout_marginEnd="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:layout_alignParentEnd="true"
android:drawablePadding="10dp"
android:drawableTint="#color/blackColor"
android:fontFamily="#font/nunito_regular"
android:gravity="center"
android:textAllCaps="true"
android:text="Next"
android:textColor="#color/blackColor"
android:textSize="16sp"
android:visibility="visible" />
<androidx.cardview.widget.CardView
android:id="#+id/cvSubmit"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginEnd="5dp"
android:minWidth="80dp"
android:visibility="gone"
android:clickable="true"
android:padding="5dp"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:layout_alignParentEnd="true"
app:cardCornerRadius="4dp">
<LinearLayout
android:id="#+id/llCard"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tvBtnCreateAssignmentSubmit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#584056"
android:clickable="true"
android:fontFamily="#font/nunito_regular"
android:text="Submit"
android:layout_gravity="center"
android:gravity="center"
android:textColor="#color/whiteColor"
android:textSize="16sp"
android:visibility="visible" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
layout_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:layout_marginBottom="5dp"
android:background="#fcfbfc"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/lblPoint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="4dp"
android:fontFamily="#font/nunito_light"
android:textColor="#color/blackColor"
android:textSize="12sp"
tools:text="10 Points" />
<RelativeLayout
android:id="#+id/rlheader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:visibility="visible"
>
<TextView
android:id="#+id/lblques"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerInParent="true"
android:layout_marginStart="1dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="4dp"
android:fontFamily="#font/nunito_light"
android:textColor="#color/blackColor"
android:textSize="14sp"
tools:text="15." />
<TextView
android:id="#+id/tvQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="10dp"
android:fontFamily="#font/nunito_regular"
android:gravity="center_vertical"
android:layout_centerInParent="true"
android:layout_toStartOf="#+id/edPoint"
android:minLines="2"
tools:text="Who from the following is responsible for this question"
android:textSize="16sp"
android:scrollbars="vertical"
android:textColor="#color/blackColor" />
<TextView
android:id="#+id/tvPoint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="4dp"
android:fontFamily="#font/nunito_light"
android:gravity="center"
android:visibility="gone"
android:minLines="1"
android:textColor="#color/blackColor"
android:textSize="16sp"
tools:text="/10" />
<EditText
android:id="#+id/edPoint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:visibility="gone"
android:layout_centerInParent="true"
android:fontFamily="#font/nunito_light"
android:gravity="center"
android:minLines="1"
android:inputType="number"
tools:text="100"
android:imeOptions="actionDone"
android:layout_toStartOf="#+id/tvPoint"
android:textSize="14sp"
android:textColor="#color/blackColor" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlAnswer"
android:layout_marginTop="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:elevation="5dp"
android:background="#drawable/shape_square"
android:layout_marginBottom="20dp"
android:minHeight="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:padding="10dp"
android:id="#+id/edAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito_regular"
android:gravity="top"
tools:text="assfadasffdsdfddfd"
android:layout_gravity="top"
android:textSize="16sp"
android:scrollbars="vertical"
android:textColor="#color/blackColor" />
</RelativeLayout>
<LinearLayout
android:id="#+id/llOptions"
android:orientation="vertical"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:clickable="false"
android:id="#+id/llOpt1"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/rbOpt1"
android:layout_marginEnd="#dimen/_10sdp"
android:layout_width="wrap_content"
android:clickable="false"
android:buttonTint="#color/darkGreyColor"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:clickable="false"
android:id="#+id/llOpt2"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/rbOpt2"
android:layout_marginEnd="#dimen/_10sdp"
android:layout_width="wrap_content"
android:clickable="false"
android:buttonTint="#color/darkGreyColor"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:id="#+id/llOpt3"
android:clickable="false"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/rbOpt3"
android:layout_marginEnd="#dimen/_10sdp"
android:layout_width="wrap_content"
android:clickable="false"
android:buttonTint="#color/darkGreyColor"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:id="#+id/llOpt4"
android:clickable="false"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/rbOpt4"
android:layout_marginEnd="#dimen/_10sdp"
android:layout_width="wrap_content"
android:clickable="false"
android:buttonTint="#color/darkGreyColor"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<androidx.cardview.widget.CardView
app:cardCornerRadius="8dp"
android:id="#+id/cvDocPreview"
android:visibility="visible"
android:layout_marginTop="4dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/llCreateAssignmentParent1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/whiteColor"
android:gravity="center_vertical"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="#+id/cardImage"
app:cardElevation="0dp"
android:layout_width="#dimen/_60sdp"
android:layout_height="#dimen/_40sdp">
<ImageView
android:id="#+id/ivPreviewItem"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="match_parent"
android:minHeight="60dp"
android:src="#drawable/ic_file_black"
android:background="#color/thumbnail_background"
android:adjustViewBounds="true"
android:scaleType="centerInside"/>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_toRightOf="#+id/cardImage"
android:id="#+id/llFileUpload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="40dp"
android:layout_marginBottom="5dp"
android:orientation="vertical">
<TextView
android:id="#+id/tvFileNameItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:letterSpacing="0.02"
android:ellipsize="end"
android:layout_marginEnd="5dp"
android:maxLines="1"
android:fontFamily="#font/nunito_bold"
android:lineSpacingExtra="0sp"
android:textColor="#000000"
android:textSize="14sp"
tools:text="Filename.ext" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvFileType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:letterSpacing="0.02"
android:textColor="#000000"
android:textSize="12sp"
android:maxLines="1"
android:ellipsize="end"
android:layout_marginEnd="4dp"
android:fontFamily="#font/nunito_regular"
tools:text="File Type" />
<View
android:id="#+id/viewDivide"
android:layout_gravity="center"
android:background="#color/black_half"
android:layout_width="1dp"
android:layout_height="#dimen/_10sdp"/>
<TextView
android:id="#+id/tvFileSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:letterSpacing="0.02"
android:textColor="#000000"
android:textSize="12sp"
android:maxLines="1"
android:ellipsize="end"
android:layout_marginStart="4dp"
android:fontFamily="#font/nunito_regular"
android:text="24 mb" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:padding="7dp"
android:layout_centerInParent="true"
android:layout_alignParentEnd="true"
android:visibility="visible"
android:id="#+id/ibDownloadItem"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="4dp"
android:background="#color/whiteColor"
android:tint="#color/blackColor"
android:src="#android:drawable/stat_sys_download" />
</RelativeLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/tvNotAttempted"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="4dp"
android:layout_gravity="center"
android:visibility="gone"
android:fontFamily="#font/nunito_light"
android:gravity="center"
android:text="Question not attempted"
android:minLines="1"
android:textColor="#color/redWarningColor"
android:textSize="16sp" />
<TextView
android:id="#+id/tvMandatory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_gravity="center"
android:visibility="gone"
android:fontFamily="#font/nunito_light"
android:gravity="center"
android:text="Mandatory Question*"
android:minLines="1"
android:textColor="#color/redWarningColor"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
Before Pressing Next
Returning to the previous item it just wraps views
Please help, I am stuck for 2 weeks

After adding a ScrollView, the the app title is no longer displayed

Hi in the below code i have a login layout in that contains email id and password are the attributes.
Now want to display my layout in landscape mode.because of that i just added scrollview.
Now my problem is after adding the scrollview to my layout "LOGIN" title not showing .
can any one please help me
<?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="#1c1c1c">
<RelativeLayout
android:id="#+id/toolbarRel"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:layout_gravity="center_vertical"
android:background="#color/color_toolbar">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login"
android:textColor="#color/white"
android:textSize="#dimen/heading_font_size"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1c1c1c"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbarRel"
android:layout_centerInParent="true"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"
android:paddingEnd="#dimen/activity_horizontal_margin"
android:layout_marginTop="20dp"
android:paddingStart="#dimen/activity_horizontal_margin">
<EditText
android:id="#+id/et_email"
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textfield_outer_box"
android:drawablePadding="10dp"
android:drawableStart="#drawable/img_email_icon"
android:drawableLeft="#drawable/img_email_icon"
android:ems="10"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:paddingStart="10dp"
android:paddingEnd="10dp"/>
<EditText
android:id="#+id/et_pwd"
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/homogeneous_margin"
android:background="#drawable/textfield_outer_box"
android:drawablePadding="10dp"
android:drawableStart="#drawable/img_password_icon"
android:drawableLeft="#drawable/img_password_icon"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:paddingEnd="10dp"
android:paddingStart="10dp" />
<Button
android:id="#+id/btn_login"
style="#style/style_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/heterogenous_margin"
android:background="#drawable/login_button"
android:paddingBottom="#dimen/button_topbottom_padding"
android:text="#string/get_started" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/homogeneous_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:textSize="18sp"
android:textColor="#android:color/white"
android:id="#+id/txt_forgot_password"/>
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="#dimen/homogeneous_margin"
android:gravity="center"
android:text="Create Account"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/common_text"
android:layout_marginBottom="13dp"
android:text="or sign with"
android:visibility="gone"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="2"
android:visibility="visible">
<!--<com.facebook.login.widget.LoginButton-->
<!--android:id="#+id/login_button"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginBottom="8dp"-->
<!--android:layout_marginLeft="8dp"-->
<!--android:layout_margin="4dp"-->
<!--android:layout_paddinBottom="12dp"-->
<!--android:layout_paddingTop="12dp"-->
<!--android:gravity="center"-->
<!--android:layout_weight="1"-->
<!--/>-->
<!--<com.google.android.gms.common.SignInButton-->
<!--android:id="#+id/signin_button"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_centerInParent="true"-->
<!--android:layout_weight="1"/>-->
</LinearLayout>
</RelativeLayout>
Your title is not displaying because the height of your ScrollView is match_parent
So your RelativeLayout is hiding behind ScrollView
Just add android:layout_below="#id/toolbarRel" in your ScrollView
SAMPLE CODE
<?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="#1c1c1c">
<RelativeLayout
android:id="#+id/toolbarRel"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical"
android:background="#color/color_toolbar">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login"
android:textColor="#color/white"
android:textSize="#dimen/heading_font_size"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/toolbarRel"
android:background="#1c1c1c"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbarRel"
android:layout_centerInParent="true"
android:layout_marginTop="20dp"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"
android:paddingStart="#dimen/activity_horizontal_margin"
android:paddingEnd="#dimen/activity_horizontal_margin">
<EditText
android:id="#+id/et_email"
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textfield_outer_box"
android:drawableStart="#drawable/img_email_icon"
android:drawableLeft="#drawable/img_email_icon"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<EditText
android:id="#+id/et_pwd"
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/homogeneous_margin"
android:background="#drawable/textfield_outer_box"
android:drawableStart="#drawable/img_password_icon"
android:drawableLeft="#drawable/img_password_icon"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<Button
android:id="#+id/btn_login"
style="#style/style_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/heterogenous_margin"
android:background="#drawable/login_button"
android:paddingBottom="#dimen/button_topbottom_padding"
android:text="#string/get_started" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/homogeneous_margin">
<TextView
android:id="#+id/txt_forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:text="Forgot Password?"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="#dimen/homogeneous_margin"
android:gravity="center"
android:text="Create Account"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<TextView
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="13dp"
android:text="or sign with"
android:visibility="gone" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="2">
<!--<com.facebook.login.widget.LoginButton-->
<!--android:id="#+id/login_button"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginBottom="8dp"-->
<!--android:layout_marginLeft="8dp"-->
<!--android:layout_margin="4dp"-->
<!--android:layout_paddinBottom="12dp"-->
<!--android:layout_paddingTop="12dp"-->
<!--android:gravity="center"-->
<!--android:layout_weight="1"-->
<!--/>-->
<!--<com.google.android.gms.common.SignInButton-->
<!--android:id="#+id/signin_button"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_centerInParent="true"-->
<!--android:layout_weight="1"/>-->
</LinearLayout>
</RelativeLayout>
UPDATE
<?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="#1c1c1c">
<RelativeLayout
android:id="#+id/toolbarRel"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:textColor="#android:color/white"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/toolbarRel"
android:layout_centerInParent="true"
android:background="#1c1c1c"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"
android:paddingStart="#dimen/activity_horizontal_margin"
android:paddingEnd="#dimen/activity_horizontal_margin">
<EditText
android:id="#+id/et_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<EditText
android:id="#+id/et_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<Button
android:id="#+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="get_started" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txt_forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:text="Forgot Password?"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="Create Account"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="13dp"
android:text="or sign with"
android:visibility="gone" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="2">
</LinearLayout>
</RelativeLayout>

I want a custom dialogue with close button

Here is the imageI have done the coding but issue is that when i open dialog,close button show only half. It only shows the portion of close button inside of relative layout.
Outside part has not been shown. I am trying from hours but still not get the solution. So if any one has idea then please help me.
Thanks in advance. !
Below is my code.
<?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="#android:color/transparent">
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="255dp"
android:layout_height="385dp"
android:layout_centerInParent="true"
android:background="#android:color/white"
android:orientation="vertical" >
<Button
android:id="#+id/btn_From_Gallary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:padding="20dp"
android:layout_marginTop="60dp"
android:layout_marginBottom="16dp"
android:text="Choose From Gallary"
android:background="#color/colorAccent"
android:textColor="#ffffff"
android:textSize="16sp" />
<Button
android:id="#+id/btn_Camera"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_below="#+id/btn_From_Gallary"
android:padding="20dp"
android:text="Take a Picture"
android:background="#color/colorAccent"
android:textColor="#ffffff"
android:textSize="16sp" />
<Button
android:id="#+id/btn_Send_Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_below="#+id/btn_From_Gallary"
android:padding="20dp"
android:text="Text"
android:background="#color/colorAccent"
android:textColor="#ffffff"
android:textSize="16sp" />
<EditText
android:id="#+id/edt_notification_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:visibility="gone"
android:background="#drawable/edittext_border"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="5"
android:maxLength="250"
android:maxLines="3"
android:padding="5dp"
android:scrollbars="vertical" />
<ImageView
android:id="#+id/image"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:gravity="top|left"
android:visibility="gone"
android:inputType="textMultiLine"
android:lines="5"
android:maxLength="250"
android:maxLines="3"
android:padding="5dp"
android:scrollbars="vertical" />
<Button
android:id="#+id/btn_Send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:visibility="gone"
android:layout_marginRight="16dp"
android:layout_marginTop="50dp"
android:layout_marginBottom="20dp"
android:layout_below="#+id/btn_From_Gallary"
android:padding="20dp"
android:text="Send"
android:background="#color/colorAccent"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
<ImageView
android:id="#+id/img_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/relativeLayout1"
android:layout_alignTop="#+id/relativeLayout1"
android:layout_marginRight="-10dp"
android:layout_marginTop="-10dp"
android:src="#drawable/ic_cancel" /></RelativeLayout>
Use below code:
<?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="#android:color/transparent">
<LinearLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#android:color/white"
android:orientation="vertical">
<Button
android:id="#+id/btn_From_Gallary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="60dp"
android:background="#color/colorAccent"
android:padding="20dp"
android:text="Choose From Gallary"
android:textColor="#ffffff"
android:textSize="16sp" />
<Button
android:id="#+id/btn_Camera"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_From_Gallary"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="#color/colorAccent"
android:padding="20dp"
android:text="Take a Picture"
android:textColor="#ffffff"
android:textSize="16sp" />
<Button
android:id="#+id/btn_Send_Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_From_Gallary"
android:layout_marginBottom="20dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="20dp"
android:background="#color/colorAccent"
android:padding="20dp"
android:text="Text"
android:textColor="#ffffff"
android:textSize="16sp" />
<EditText
android:id="#+id/edt_notification_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="5"
android:maxLength="250"
android:maxLines="3"
android:padding="5dp"
android:scrollbars="vertical"
android:visibility="gone"
android:background="#drawable/edittext_border" />
<ImageView
android:id="#+id/image"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="5"
android:maxLength="250"
android:maxLines="3"
android:padding="5dp"
android:scrollbars="vertical"
android:visibility="gone" />
<Button
android:id="#+id/btn_Send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/btn_From_Gallary"
android:layout_marginBottom="20dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="50dp"
android:background="#color/colorAccent"
android:padding="20dp"
android:text="Send"
android:textColor="#ffffff"
android:textSize="16sp"
android:visibility="gone" />
</LinearLayout>
<ImageView
android:id="#+id/img_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/relativeLayout1"
android:layout_alignTop="#+id/relativeLayout1"
android:src="#drawable/ic_cancel" />
</RelativeLayout>
Try this
<RelativeLayout 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="wrap_content"
android:background="#android:color/transparent">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="30dp"
android:layout_marginTop="57dp"
android:background="#color/colorWhite"
android:orientation="vertical">
<Button
android:id="#+id/btn_From_Gallary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:padding="20dp"
android:layout_marginTop="60dp"
android:layout_marginBottom="16dp"
android:text="Choose From Gallary"
android:background="#color/colorAccent"
android:textColor="#ffffff"
android:textSize="16sp" />
<Button
android:id="#+id/btn_Camera"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_below="#+id/btn_From_Gallary"
android:padding="20dp"
android:text="Take a Picture"
android:background="#color/colorAccent"
android:textColor="#ffffff"
android:textSize="16sp" />
<Button
android:id="#+id/btn_Send_Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_below="#+id/btn_From_Gallary"
android:padding="20dp"
android:text="Text"
android:background="#color/colorAccent"
android:textColor="#ffffff"
android:textSize="16sp" />
<EditText
android:id="#+id/edt_notification_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:visibility="gone"
android:background="#drawable/edittext_border"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="5"
android:maxLength="250"
android:maxLines="3"
android:padding="5dp"
android:scrollbars="vertical" />
<ImageView
android:id="#+id/image"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:gravity="top|left"
android:visibility="gone"
android:inputType="textMultiLine"
android:lines="5"
android:maxLength="250"
android:maxLines="3"
android:padding="5dp"
android:scrollbars="vertical" />
<Button
android:id="#+id/btn_Send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:visibility="gone"
android:layout_marginRight="16dp"
android:layout_marginTop="50dp"
android:layout_marginBottom="20dp"
android:layout_below="#+id/btn_From_Gallary"
android:padding="20dp"
android:text="Send"
android:background="#color/colorAccent"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
<ImageView
android:id="#+id/img_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="-35dp"
android:layout_marginTop="35dp"
/>
</RelativeLayout>

Android layout refreshes when a picture of an ImageView is changed

I have a layout with a ScrollView.When I change the picture of an ImageView or Text of TextView, layout refreshes and screen goes to the top.I Think the problem is in ScrollView.
XML file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/sv2"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFEEEEEE"
android:orientation="vertical"
android:padding="0dp"
tools:context="hamrahyper.rayanpejuhanparse.jamshidiasl.hamrahyper.Main3Activity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFEEEEEE">
<EditText
android:id="#+id/editText3"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/imageViewx"
android:layout_toRightOf="#+id/imageViewx"
android:background="#color/colorPrimary"
android:ems="10"
android:gravity="center"
android:hint="جستجو در همراهایپر"
android:inputType="textPersonName"
android:textColor="#android:color/background_light"
android:textColorHint="#android:color/background_light"
android:textSize="14sp"
app:layout_constraintEnd_toStartOf="#+id/imageView1"
app:layout_constraintStart_toEndOf="#+id/imageViewx"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignEnd="#+id/editText3"
android:layout_alignRight="#+id/editText3"
android:layout_alignTop="#+id/editText3"
android:background="#color/colorPrimary"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#mipmap/i1" />
<ImageView
android:id="#+id/imageViewx"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#color/colorPrimary"
app:layout_constraintStart_toEndOf="#+id/imageView10"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#mipmap/icart2" />
<ViewFlipper
android:id="#+id/viewFlipper"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:autoStart="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText3">
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
app:srcCompat="#mipmap/btn1" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
app:srcCompat="#mipmap/btn2" />
</ViewFlipper>
<TextView
android:id="#+id/textView16"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:gravity="right"
android:text="دسته بندی محصولات"
android:textColor="#android:color/background_dark"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/viewFlipper" />
<HorizontalScrollView
android:id="#+id/sc1"
android:layout_width="0dp"
android:layout_height="220dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView16">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:elevation="5dp"
app:cardElevation="5dp">
<RelativeLayout
android:id="#+id/rl1"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#android:color/background_light"
android:padding="5dp">
<ImageView
android:id="#+id/im1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:srcCompat="#mipmap/icon1" />
<TextView
android:id="#+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/im1"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/tx1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/tv1"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/holo_green_dark"
android:textSize="12sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:elevation="5dp"
app:cardElevation="5dp">
<RelativeLayout
android:id="#+id/rl2"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#android:color/background_light"
android:padding="5dp">
<ImageView
android:id="#+id/im2"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:srcCompat="#mipmap/icon1" />
<TextView
android:id="#+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/im2"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/tx2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tv2"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/holo_green_dark"
android:textSize="12sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:elevation="5dp"
app:cardElevation="5dp">
<RelativeLayout
android:id="#+id/rl3"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#android:color/background_light"
android:padding="5dp">
<ImageView
android:id="#+id/im3"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:srcCompat="#mipmap/icon1" />
<TextView
android:id="#+id/tv3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/im3"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/tx3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv3"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/holo_green_dark"
android:textSize="12sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:elevation="5dp"
app:cardElevation="5dp">
<RelativeLayout
android:id="#+id/rl4"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#android:color/background_light"
android:padding="5dp">
<ImageView
android:id="#+id/im4"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:srcCompat="#mipmap/icon1" />
<TextView
android:id="#+id/tv4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/im4"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/tx4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tv4"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/holo_green_dark"
android:textSize="12sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:elevation="5dp"
app:cardElevation="5dp">
<RelativeLayout
android:id="#+id/rl5"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#android:color/background_light"
android:padding="5dp">
<ImageView
android:id="#+id/im5"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:srcCompat="#mipmap/icon1" />
<TextView
android:id="#+id/tv5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/im5"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/tx5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tv5"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/holo_green_dark"
android:textSize="12sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:elevation="5dp"
app:cardElevation="5dp">
<RelativeLayout
android:id="#+id/rl6"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#android:color/background_light"
android:padding="5dp">
<ImageView
android:id="#+id/im6"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:srcCompat="#mipmap/icon1" />
<TextView
android:id="#+id/tv6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/im6"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/black"
android:textSize="14sp" />
<TextView
android:id="#+id/tx6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tv6"
android:gravity="center_horizontal"
android:padding="5dp"
android:text="..."
android:textColor="#android:color/holo_green_dark"
android:textSize="12sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</HorizontalScrollView>
<ImageView
android:id="#+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"
app:layout_constraintTop_toBottomOf="#+id/sc1"
app:srcCompat="#mipmap/btn5"
tools:layout_editor_absoluteX="0dp" />
<TextView
android:id="#+id/textView17"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:gravity="right"
android:text="پرفروش ترین محصولات"
android:textColor="#android:color/background_dark"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView6" />
<TextView
android:id="#+id/textView19"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginStart="8dp"
android:layout_marginTop="2dp"
android:background="#mipmap/bdr3"
android:gravity="center"
android:paddingLeft="1dp"
android:paddingTop="1dp"
android:textColor="#android:color/background_dark"
android:textSize="10sp"
app:layout_constraintStart_toEndOf="#+id/imageView10"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/imageView10"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#color/colorPrimary"
android:paddingBottom="6dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="6dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#mipmap/menuicon" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</ScrollView>
I think the problem is ScrollView, so I set a focusable property of ScrollView to false but the problem not resolved.What is wrong?
Add this line android:fillViewport="true"
<ScrollView
android:fillViewport="true">
</ScrollView>

Place ImageButton in the center of ImageView

How can I adjust the imageButton in the center of ImageView?
Below are the code I have tried:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/Theme.AppCompat"
android:background="#color/darkpurple"
android:minHeight="?attr/actionBarSize">
<Button
android:text="Save"
android:id="#+id/save"
android:background="#color/darkpurple"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:textColor="#fff"
android:layout_height="wrap_content"
android:textSize="12sp" />
</android.support.v7.widget.Toolbar>
<ImageView
android:layout_height="200dp"
android:layout_width="200dp"
android:layout_marginTop="15dp"
android:background="#color/light_gray"
android:layout_below="#+id/toolbar"
android:layout_marginRight="25dp"
android:layout_alignParentRight="true"
android:id="#+id/imageView"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="65dp"
android:background="#drawable/camera"
android:layout_height="55dp"
android:layout_marginRight="5dp"
android:id="#+id/imageButtonOne"
android:paddingTop="100dp"
android:layout_marginTop="67dp"
android:layout_alignTop="#+id/imageView"
android:layout_alignRight="#+id/comments"
android:layout_alignEnd="#+id/comments" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/imageView"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textColor="#color/red"
android:textStyle="bold"
android:id="#+id/Date"
android:textSize="15sp"
android:text="Date"/>
<EditText
android:layout_width="match_parent"
android:id="#+id/date"
android:layout_below="#+id/Date"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:textSize="15sp"
android:hint="Date"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textColor="#color/red"
android:textStyle="bold"
android:id="#+id/Amount"
android:textSize="15sp"
android:text="Amount"
android:layout_below="#+id/date" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/Amount"
android:paddingLeft="20dp"
android:id="#+id/amount"
android:inputType="numberDecimal"
android:textSize="15sp"
android:hint="Amount"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textStyle="bold"
android:id="#+id/Comments"
android:textSize="15sp"
android:text="Comments"
android:layout_below="#+id/amount" />
<EditText
android:layout_width="290dp"
android:layout_height="120dp"
android:paddingBottom="80dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="10dp"
android:paddingLeft="13dp"
android:id="#+id/comments"
android:textSize="15sp"
android:background="#drawable/roundedcorner_edittext"
android:hint="Comments"
android:layout_below="#+id/Comments"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
My ScreenShot
<FrameLayout android:layout_height="200dp"
android:layout_width="200dp"
android:layout_below="#+id/toolbar"
android:layout_marginRight="25dp"
android:layout_marginTop="15dp"
android:layout_alignParentRight="true">
<ImageView
android:layout_height="200dp"
android:layout_width="200dp"
android:background="#color/light_gray"
android:id="#+id/imageView"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="65dp"
android:background="#drawable/camera"
android:layout_height="55dp"
android:id="#+id/imageButtonOne"
android:layout_gravity = "center"
/>
</FrameLayout>
Check it.
Use code, it works for all screen size(Please replace image with yours):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/Theme.AppCompat"
android:background="#color/colorPrimary"
android:minHeight="?attr/actionBarSize">
<Button
android:text="Save"
android:id="#+id/save"
android:background="#color/colorPrimary"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:textColor="#fff"
android:layout_height="wrap_content"
android:textSize="12sp" />
</android.support.v7.widget.Toolbar>
<ImageView
android:layout_height="200dp"
android:layout_width="200dp"
android:layout_marginTop="15dp"
android:background="#color/colorPrimary"
android:layout_below="#+id/toolbar"
android:layout_marginRight="25dp"
android:layout_alignParentRight="true"
android:id="#+id/imageView"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="70dp"
android:background="#mipmap/ic_launcher"
android:layout_height="60dp"
android:layout_marginTop="70dp"
android:layout_marginRight="65dp"
android:id="#+id/imageButtonOne"
android:layout_alignTop="#+id/imageView"
android:layout_alignEnd="#+id/imageView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/imageView"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:id="#+id/Date"
android:textSize="15sp"
android:text="Date"/>
<EditText
android:layout_width="match_parent"
android:id="#+id/date"
android:layout_below="#+id/Date"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:textSize="15sp"
android:hint="Date"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:id="#+id/Amount"
android:textSize="15sp"
android:text="Amount"
android:layout_below="#+id/date" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/Amount"
android:paddingLeft="20dp"
android:id="#+id/amount"
android:inputType="numberDecimal"
android:textSize="15sp"
android:hint="Amount"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textStyle="bold"
android:id="#+id/Comments"
android:textSize="15sp"
android:text="Comments"
android:layout_below="#+id/amount" />
<EditText
android:layout_width="290dp"
android:layout_height="120dp"
android:paddingBottom="80dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="10dp"
android:paddingLeft="13dp"
android:id="#+id/comments"
android:textSize="15sp"
android:background="#mipmap/ic_launcher"
android:hint="Comments"
android:layout_below="#+id/Comments"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
The idea is simple, make changes according to this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="250dp"
android:layout_height="250dp" >
<ImageView
android:id="#+id/base"
android:layout_height="250dp"
android:layout_width="250dp"
android:src="#drawable/home"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<ImageButton
android:id="#+id/center"
android:layout_height="150dp"
android:layout_width="150dp"
android:src="#drawable/home"
android:layout_centerInParent="true"
android:layout_centerVertical="true" />
</RelativeLayout>
</RelativeLayout>
In order to move it to the top right corner, you can specify
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
to the Relative Layout with fixed widths, This places the Layout at the top right corner, then you can add margins to keep at a position where you require.
Hope it helps :)
Past this as it is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/Theme.AppCompat"
android:background="#color/darkpurple"
android:minHeight="?attr/actionBarSize">
<Button
android:text="Save"
android:id="#+id/save"
android:background="#color/darkpurple"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:textColor="#fff"
android:layout_height="wrap_content"
android:textSize="12sp" />
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:id="#+id/rlImages"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_below="#+id/toolbar"
android:layout_marginRight="25dp"
android:layout_marginTop="15dp">
<ImageView
android:id="#+id/imageView"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#color/light_gray" />
<Button
android:id="#+id/imageButtonOne"
android:layout_width="65dp"
android:layout_height="55dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/add_tag" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/rlImages"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textColor="#color/red"
android:textStyle="bold"
android:id="#+id/Date"
android:textSize="15sp"
android:text="Date"/>
<EditText
android:layout_width="match_parent"
android:id="#+id/date"
android:layout_below="#+id/Date"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:textSize="15sp"
android:hint="Date"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textColor="#color/red"
android:textStyle="bold"
android:id="#+id/Amount"
android:textSize="15sp"
android:text="Amount"
android:layout_below="#+id/date" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/Amount"
android:paddingLeft="20dp"
android:id="#+id/amount"
android:inputType="numberDecimal"
android:textSize="15sp"
android:hint="Amount"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="20dp"
android:textStyle="bold"
android:id="#+id/Comments"
android:textSize="15sp"
android:text="Comments"
android:layout_below="#+id/amount" />
<EditText
android:layout_width="290dp"
android:layout_height="120dp"
android:paddingBottom="80dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="10dp"
android:paddingLeft="13dp"
android:id="#+id/comments"
android:textSize="15sp"
android:background="#drawable/roundedcorner_edittext"
android:hint="Comments"
android:layout_below="#+id/Comments"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
You need to use RelativeLayout with the use of
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
You can use FrameLayout with that
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="#drawable/img" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_gravity="center_horizontal|bottom"
android:padding="12dip"
android:background="#000000"
android:textColor="#ffffffff"
android:text="Button" />
</FrameLayout>

Categories

Resources