Button is not showing on View - android

I have a View in my activity where it contains one image, a text and a button...
So as you can see my button is showing there but its not visible...
It is going behind, I have tried to test it by marginTop attribute and if I move it down from the view then its visible...
I don't know how to do this but with the TextView when I use background then it changes the background color & works fine..
But I want to use Button instead of TextView
How can I do this or what I will have to do to bring the button front?
Below is my xml file code
<?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"
tools:context=".Dashboard">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#drawable/dashboard_layout"
android:elevation="6dp"
android:transitionName="bg_anim"
android:layout_alignParentTop="true"
/>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="6dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!--This is the button-->
<!--Removed <Button
android:id="#+id/tv_welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:backgroundTint="#color/black"
android:elevation="6dp"
android:text="Hello,"
android:textColor="#fff"
android:textSize="35sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar" />
-->
<--added newly-->
<Button
android:id="#+id/tv_welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:backgroundTint="#color/black"
android:elevation="6dp"
android:text="Hello,"
android:textColor="#fff"
android:textSize="35sp"
android:layout_alignParentStart="true"
android:layout_below="#+id/toolbar"/>
<TextView
android:id="#+id/tv_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="6dp"
android:text="Username"
android:textColor="#B2FFFFFF"
android:textSize="22sp"
android:transitionName="user_anim"
app:layout_constraintStart_toStartOf="#+id/tv_welcome"
app:layout_constraintTop_toTopOf="#+id/guideline3" />
<ImageView
android:id="#+id/iv_display_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:elevation="6dp"
android:padding="8dp"
android:transitionName="profile_anim"
android:layout_centerHorizontal="true"
app:layout_constraintDimensionRatio="h,1:1"
app:srcCompat="#drawable/ic_undraw_male_avatar" />
<TextView
android:id="#+id/tv_dashboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="48dp"
android:layout_marginTop="16dp"
android:text="Your Dashboard"
android:textColor="#ff1122"
android:textSize="20sp"
android:layout_below="#+id/view"/>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
After changing some code...

You are using RelativeLayout as parent and adding constraints to Button which only works when the parent is ConstraintLayout, to achieve same in RelativeLayout try android:layout_alignParentStart="true" and android:layout_below="#+id/toolbar" as in
<Button
android:id="#+id/tv_welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:backgroundTint="#color/black"
android:elevation="6dp"
android:text="Hello,"
android:textColor="#fff"
android:textSize="35sp"
android:layout_alignParentStart="true"
android:layout_below="#+id/toolbar" />
Also remove elevation on View as it is just setting background
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="#drawable/dashboard_layout"
android:transitionName="bg_anim"
android:layout_alignParentTop="true"/>

<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="match_parent">
<RelativeLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/header_cover_image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#drawable/my_gradient_background"
android:orientation="vertical"
android:scaleType="centerCrop"
/>
<ImageView
android:id="#+id/profile"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_below="#+id/header_cover_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="-150dp"
android:clickable="true"
android:elevation="5dp"
android:padding="20dp"
android:scaleType="centerCrop"
android:src="#drawable/app_icon"
app:civ_border_color="#FFFFFFFF"
app:civ_border_width="3dp" />
<RelativeLayout
android:id="#+id/profile_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/header_cover_image"
android:layout_marginLeft="10dp"
android:layout_marginTop="-50dp"
android:layout_marginRight="10dp"
android:background="#drawable/white_rounded_corner"
android:elevation="4dp"
android:paddingBottom="24dp">
<ImageView
android:id="#+id/save_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:visibility="gone"
android:layout_marginRight="20dp"
android:clickable="true"
android:src="#android:drawable/ic_menu_save" />
<ImageView
android:id="#+id/edit_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:clickable="true"
android:src="#android:drawable/ic_menu_edit" />
<EditText
android:id="#+id/user_name_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:background="#android:color/transparent"
android:inputType="none"
android:ems="50"
android:ellipsize="end"
android:focusable="false"
android:gravity="center"
android:maxLines="1"
android:text="Laxman Marothiya"
android:textColor="#000"
android:textSize="#dimen/normal_subTitle_font_size_eighteen"
android:textStyle="bold" />
<EditText
android:id="#+id/gender_info_textv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/user_name_info"
android:layout_centerHorizontal="true"
android:background="#android:color/transparent"
android:inputType="none"
android:focusable="false"
android:gravity="center"
android:ems="6"
android:maxLines="1"
android:text="Male"
android:textColor="#000"
android:textSize="#dimen/normal_subTitle_font_size_eighteen" />
<EditText
android:id="#+id/email_info_textv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/gender_info_textv"
android:layout_centerHorizontal="true"
android:background="#android:color/transparent"
android:inputType="none"
android:focusable="false"
android:gravity="center"
android:ems="40"
android:maxLines="1"
android:text="Emaol#gmail.com"
android:textColor="#000"
android:textSize="#dimen/normal_text_size_fifteen" />
<EditText
android:id="#+id/bio_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/email_info_textv"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
android:background="#android:color/transparent"
android:inputType="none"
android:focusable="false"
android:gravity="center"
android:padding="8dp"
android:ellipsize="end"
android:ems="200"
android:text="Here is my bio can you see it actually this is very interesting here "
android:textColor="#color/appBlackColor"
android:textSize="#dimen/normal_text_size_fifteen" />
</RelativeLayout>
</RelativeLayout>

Related

Is there a way to scroll behind the keyboard on Android?

I have a screen with view that get affected when the soft keyboard appears, the entire white portion is in a ScrollView:
When I set the windowSoftInputMode to adjustPan in the manifest, the keyboard covers the save button, which can't be pressed until the keyboard is collapsed:
If I set it to adjustResize, the the views are all raised to overlap each other:
In neither case does the screen scroll. What I would like is for all of the views to remain in their original positions, but allow the user to scroll to the bottom behind the keyboard, until the bottom of the screen below the save button is adjacent to the top of the open keyboard. Is this possible?
Edit: .xml layout:
<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:fillViewport="true"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<FrameLayout
android:id="#+id/paypalActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#color/app_yellow_bold">
<TextView
android:id="#+id/paypalToastContainer"
android:tag="paypal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#color/onboarding_button_blue"
android:elevation="1dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="30dp"
android:paddingBottom="5dp"
android:visibility="gone"
android:text="#string/payout_pay_pal_saved"
android:textColor="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="gone">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/radikal_bold"
android:paddingTop="50dp"
android:paddingBottom="30dp"
android:text="#string/payout_pay_pal_connect_title"
android:textColor="#color/black"
android:textSize="30sp"/>
<com.weare8.android.ui.widgets.BackButton
android:id="#+id/pp_back"
android:layout_width="wrap_content"
android:layout_marginTop="20dp"
android:layout_height="match_parent"/>
</FrameLayout>
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintTop_toBottomOf="#+id/paypalActionBar">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/paypalActionBar" android:id="#+id/frameLayout4">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/paypal_logo"
android:layout_width="252dp"
android:layout_height="67dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:src="#drawable/paypal_logo"/>
<TextView
android:id="#+id/paypalDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/paypal_logo"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:fontFamily="#font/radikal"
android:lineSpacingMultiplier="1.2"
android:text="#string/payout_pay_pal_description"
android:textColor="#color/app_dark_gray"
android:textSize="16sp"/>
<TextView
android:id="#+id/paypalWarning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/paypalDescription"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:fontFamily="#font/radikal"
android:lineSpacingMultiplier="1.2"
android:textStyle="italic"
android:text="#string/payout_pay_pal_payout_warning"
android:textColor="#color/app_light_gray"
android:textSize="14sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
>
<EditText
android:id="#+id/text_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_edit_text"
android:hint="#string/payout_pay_pal_email_hint"
android:elevation="2dp"
android:imeOptions="actionDone"
android:inputType="textEmailAddress"
android:fontFamily="#font/radikal"
android:maxLines="1"
android:layout_marginBottom="15dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingStart="20dp"
android:textColor="#color/black"
android:textSize="16sp"
android:textColorHint="#8A8A8A"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/text_dont_have_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="3dp"
android:fontFamily="#font/radikal"
android:text="#string/payout_pay_pal_question"
android:textColor="#color/app_dark_gray"
android:textSize="14sp"/>
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/radikal"
android:textStyle="bold"
android:textColor="#color/button_blue"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<TextView
android:id="#+id/saveButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/bg_button_blue_rounded"
android:layout_margin="25dp"
android:fontFamily="#font/radikal_bold"
android:gravity="center"
android:padding="20dp"
android:text="#string/payout_pay_pal_save"
android:textSize="16sp"
android:textColor="#color/white"/>
</FrameLayout>
</ScrollView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
If you want to scroll and save button also show in scrolling when soft keypad open, then you should have to move scroll view from white area to top of the view.
I have made a demo for you. try this one. I hope It might be helpful.
<!--If you your scroll view top of the layout it will resolve your problem-->
<ScrollView
android:id="#+id/scroll_view"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
>
<!--Toolbar demo-->
<LinearLayout
android:id="#+id/ll_toolbar"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#color/teal_200"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<!-- <ScrollView-->
<!-- android:id="#+id/scroll_view"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="#+id/ll_toolbar"-->
<!-- >-->
<!--Your white area of scroll which you want to scroll-->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/white_portain"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ll_toolbar"
>
<TextView
android:id="#+id/tv_paypal_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PayPal"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:textColor="#color/black"
android:textSize="35dp"
/>
<TextView
android:id="#+id/tv_sub_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Connect your PayPal account to receive \n payments!"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="parent"
android:textColor="#color/black"
android:textSize="18dp"
app:layout_constraintTop_toBottomOf="#+id/tv_paypal_title"
/>
<TextView
android:id="#+id/tv_sub_2_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please note:You must have a minimum balance of \n$1.00 to make a payout via PayPal."
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="parent"
android:textColor="#color/gray_600"
android:textSize="15dp"
app:layout_constraintTop_toBottomOf="#+id/tv_sub_title"
/>
<EditText
android:id="#+id/edit_email"
android:layout_width="0dp"
android:layout_marginTop="10dp"
android:hint="Enter your email"
android:paddingStart="10dp"
android:textColorHint="#color/gray_600"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
app:layout_constraintTop_toBottomOf="#+id/tv_sub_2_title"
app:layout_constraintStart_toStartOf="#+id/tv_sub_title"
app:layout_constraintEnd_toEndOf="parent"
/>
<TextView
android:id="#+id/tv_create_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dont have a PayPal account?"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="#+id/edit_email"
android:textColor="#color/gray_600"
android:textSize="15dp"
app:layout_constraintTop_toBottomOf="#+id/edit_email"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save"
android:layout_marginTop="160dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_create_one" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!--</ScrollView>-->
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I follow your layout and try to fix it. now it's working as you want. if you get any trouble with this layout then i will happy to help you futher
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
>
<LinearLayout
android:id="#+id/ll_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical">
<FrameLayout
android:id="#+id/paypalActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#color/teal_200">
<TextView
android:id="#+id/paypalToastContainer"
android:tag="paypal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#color/black"
android:elevation="1dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="30dp"
android:paddingBottom="5dp"
android:visibility="gone"
android:text="#string/payout_pay_pal_saved"
android:textColor="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="gone">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="50dp"
android:paddingBottom="30dp"
android:text="#string/payout_pay_pal_connect_title"
android:textColor="#color/black"
android:textSize="30sp"/>
<ImageView
android:id="#+id/pp_back"
android:background="#drawable/ic_launcher_background"
android:layout_width="wrap_content"
android:layout_marginTop="20dp"
android:layout_height="match_parent"/>
</FrameLayout>
</LinearLayout>
<!-- <ScrollView android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:fillViewport="true"-->
<!-- app:layout_constraintTop_toBottomOf="#+id/paypalActionBar">-->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ll_toolbar"
android:id="#+id/frameLayout4">
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:paddingLeft="20dp"-->
<!-- android:paddingRight="20dp">-->
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/paypal_logo"
android:layout_width="252dp"
android:layout_height="67dp"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="#color/gray_600"/>
<TextView
android:id="#+id/paypalDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/paypal_logo"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
app:layout_constraintTop_toBottomOf="#+id/paypal_logo"
app:layout_constraintStart_toStartOf="#+id/paypal_logo"
android:lineSpacingMultiplier="1.2"
android:text="#string/payout_pay_pal_description"
android:textColor="#color/gray_600"
android:textSize="16sp"/>
<TextView
android:id="#+id/paypalWarning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/paypalDescription"
app:layout_constraintTop_toBottomOf="#+id/paypalDescription"
app:layout_constraintStart_toStartOf="#+id/paypalDescription"
android:layout_marginTop="5dp"
android:layout_marginEnd="20dp"
android:lineSpacingMultiplier="1.2"
android:textStyle="italic"
android:text="#string/payout_pay_pal_payout_warning"
android:textColor="#color/gray_600"
android:textSize="14sp"/>
<LinearLayout
android:id="#+id/ll_edittext"
app:layout_constraintTop_toBottomOf="#+id/paypalWarning"
app:layout_constraintStart_toStartOf="#+id/paypalDescription"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_centerInParent="true"
android:orientation="vertical"
>
<EditText
android:id="#+id/text_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/payout_pay_pal_email_hint"
android:elevation="2dp"
android:imeOptions="actionDone"
android:inputType="textEmailAddress"
android:maxLines="1"
android:layout_marginBottom="15dp"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:paddingStart="20dp"
android:textColor="#color/black"
android:textSize="16sp"
android:textColorHint="#8A8A8A"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/text_dont_have_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="3dp"
android:text="#string/payout_pay_pal_question"
android:textColor="#color/black"
android:textSize="14sp"/>
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="asd"
android:textColor="#color/purple_700"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
<!-- </RelativeLayout>-->
<View
android:id="#+id/spacing"
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/ll_edittext"
/>
<TextView
android:id="#+id/saveButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="25dp"
android:background="#color/teal_200"
android:gravity="center"
android:padding="20dp"
android:text="#string/payout_pay_pal_save"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spacing"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- </ScrollView>-->
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Try this...its working fine for me. Please change color names in this layout xml and their hex code in your values>.color .xml and also the string values to get desired results.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
tools:ignore="UnknownIdInLayout">
<LinearLayout
android:id="#+id/idLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:padding="5dp"
app:layout_constraintTop_toBottomOf="#+id/idTopic"
tools:ignore="MissingConstraints">
<TextView
android:layout_width="wrap_content"
android:layout_height="150dp"
android:layout_gravity="center"
android:gravity="center|top"
android:text="Your Text/nYourImage"
android:padding="10dp"
android:background="#00ffff"
android:textColor="#66ff33"
android:textSize="45sp"
/>
<EditText
android:id="#+id/idUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyz.#1234567890_"
android:inputType="textEmailAddress"
android:imeOptions="actionDone"
android:maxLength="40"
android:hint="email"
android:padding="10dp"
android:gravity="center"
android:layout_marginTop="15dp"
android:textSize="15sp"
android:background="#cccccc"
/>
<EditText
android:id="#+id/idPass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:imeOptions="actionDone"
android:hint="password"
android:padding="10dp"
android:gravity="center"
android:layout_marginTop="15dp"
android:textSize="15sp"
android:autofillHints=""
android:background="#cccccc"/>
<Button
android:id="#+id/idLogin"
android:layout_width="wrap_content"
android:minWidth="100dp"
android:layout_height="40dp"
android:text="login"
android:textStyle="bold"
android:textAllCaps="true"
android:gravity="center"
android:textSize="15sp"
android:layout_marginTop="10dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="#ffff00"
android:textColor="#ffffff"
/>
<Button
android:id="#+id/idReset"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="forgot"
android:textAllCaps="true"
android:gravity="center"
android:textSize="15sp"
android:layout_marginTop="30dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="#ffff00"
android:textColor="#ffffff"
/>
<Button
android:id="#+id/idSignup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="sign up"
android:textAllCaps="true"
android:gravity="center"
android:textSize="15sp"
android:layout_marginTop="30dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="#ffff00"
android:textColor="#ffffff"
/>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

Setting a Button height to wrap_content not doing what is expected

I'm trying to position a couple of buttons at the bottom of the page and have set their height to wrap_content, like so:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_container"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#color/colorAccent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<TextView
android:id="#+id/words_prompt"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_below="#+id/appbar"
android:layout_margin="10dp"
android:text="#string/words_prompt" />
<EditText
android:id="#+id/word_list"
android:singleLine="false"
android:enabled="false"
android:lines="10"
android:textStyle="bold"
android:textColor="#color/colorPrimaryDark"
android:background="#ffffff"
android:inputType="textMultiLine"
android:layout_below="#+id/words_prompt"
android:layout_margin="10dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:gravity="top"
android:layout_width="180sp"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/time_left_prompt"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/word_list"
android:layout_toEndOf="#+id/word_list"
android:layout_below="#+id/words_prompt"
android:layout_margin="10dp"
android:text="#string/time_left_prompt" />
<TextView
android:id="#+id/time_left"
android:textStyle="bold"
android:layout_below="#+id/words_prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/time_left_prompt"
android:layout_toEndOf="#+id/time_left_prompt"
android:layout_margin="10dp" />
<EditText
android:id="#+id/typed_word"
android:focusable="false"
android:maxLength="10"
android:inputType="text"
android:textCursorDrawable="#drawable/custom_cursor"
android:enabled="false"
android:layout_below="#+id/word_list"
android:digits="abcdefghijklmnopqrstuvwxyz"
android:textColor="#color/colorPrimaryDark"
android:layout_margin="10dp"
android:hint="#string/type_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/done_button"
android:enabled="false"
android:text="#string/done_prompt"
android:layout_toRightOf="#+id/typed_word"
android:layout_toEndOf="#+id/typed_word"
android:layout_alignBaseline="#+id/typed_word"
android:layout_below="#+id/word_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<include
layout="#layout/keyboardlayout_en"
android:id="#+id/keyboard_layout"
android:visibility="invisible"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/done_button"/>
<Button
android:id="#+id/start_timer_button"
android:text="#string/start_timer_prompt"
android:layout_margin="10dp"
android:layout_below="#+id/done_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/best_score_prompt"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/start_timer_button"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:text="#string/best_score_prompt" />
<TextView
android:id="#+id/best_score"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/start_timer_button"
android:layout_toRightOf="#+id/best_score_prompt"
android:layout_toEndOf="#+id/best_score_prompt"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp" />
<TextView
android:id="#+id/elapsed_time_prompt"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_below="#+id/best_score_prompt"
android:layout_margin="10dp"
android:text="#string/elapsed_time_prompt" />
<TextView
android:id="#+id/elapsed_time"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_below="#+id/best_score_prompt"
android:layout_toRightOf="#+id/elapsed_time_prompt"
android:layout_toEndOf="#+id/elapsed_time_prompt"
android:layout_margin="10dp" />
<Button
android:id="#+id/reset_button"
android:text="#string/reset_prompt"
android:enabled="false"
android:layout_alignParentBottom="true"
android:layout_below="#+id/best_score_prompt"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/quit_button"
android:text="#string/quit_prompt"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_below="#+id/best_score_prompt"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
But the layout renders as this:
Why are the heights so off and what do I need to do to fix this (without hard-coding the button height with numbers or adding top margins)?
Remove in both buttons:
android:layout_below="#+id/best_score_prompt"
With:
Without:

how do I make my edit texts appear above the keyboad

there have been similar questions like this but none of them worked for me, so here my register layout :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RegisterActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/signin_page_background" />
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="45dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="#+id/retour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:onClick="goback"
android:padding="15dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="#drawable/baseline_arrow_back_ios_24"
android:tint="#191919" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Retour"
android:textColor="#191919"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<com.github.captain_miao.optroundcardview.OptRoundCardView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:optRoundCardCornerRadius="50dp"
app:optRoundCardElevation="0dp"
app:optRoundCardLeftBottomCorner="false"
app:optRoundCardLeftTopCorner="true"
app:optRoundCardRightBottomCorner="false"
app:optRoundCardRightTopCorner="true"
app:layout_constraintTop_toBottomOf="#+id/linearLayout"
android:windowSoftInputMode="adjustPan"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:keyboardNavigationCluster="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:text="#string/inscrivez"
android:textColor="#191919"
android:textSize="25dp"
android:textStyle="bold" />
<EditText
android:id="#+id/username_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="30dp"
android:background="#android:color/transparent"
android:drawableEnd="#drawable/user_icon"
android:drawableTint="#696969"
android:hint="#string/username"
android:padding="15dp"
android:textColor="#191919"
android:textColorHint="#696969"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:background="#696969" />
<EditText
android:id="#+id/email_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="30dp"
android:background="#android:color/transparent"
android:drawableEnd="#drawable/email_icon"
android:drawableTint="#696969"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:padding="15dp"
android:textColor="#191919"
android:textColorHint="#696969"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:background="#696969" />
<EditText
android:id="#+id/pw_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="30dp"
android:background="#android:color/transparent"
android:drawableEnd="#drawable/pasword_icon"
android:drawableTint="#696969"
android:hint="#string/password"
android:inputType="textPassword"
android:padding="15dp"
android:textColor="#191919"
android:textColorHint="#696969"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:background="#696969" />
<Button
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="80dp"
android:background="#drawable/btn_signin"
android:text="#string/insc_btn"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</com.github.captain_miao.optroundcardview.OptRoundCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
whenever the screan is small, and when the user types the passwor and the keyboard hides the editText.
if anyone can correct my xml to make the editText appear above the keybord whenever the user is typing
Use ScrollView as Root layout.

How to affix a LinearLayout at the bottom of a screen in coordinator layout?

I have a situation where linearlayout doesn't stay fixed at the bottom of the co-ordinatorlayout but moves with respect to the scrollview contents above.
I have tried all solutions on StackOverflow but still no luck (ex:Keep LinearLayout at the bottom of screen and even tried relativelayout but no luck: Make a RelativeLayout at the bottom of a Scrollview ). I am not sure what could be causing this, for the linear/relativelayout to move with respect to the scrollview, but if anyone else can figure out what I am doing wrong or missing, that'll be a great help!
Thanks in advance! Here's my XML code below: (open to sharing any other relevant java code if that helps )
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:clickable="false"
android:fitsSystemWindows="true"
android:fillViewport="true"
android:id="#+id/cl_root_view"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/main_register_container"
android:layout_marginBottom="60dp"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:id="#+id/activity_register_guest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
app:subtitleTextColor="#color/white"
app:titleTextAppearance="#style/Toolbar.TitleText"
app:titleTextColor="#color/white">
<!--<TextView
android:id="#+id/nav_back_btn"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:layout_marginTop="20dp"
android:background="#drawable/ic_backarrow"
android:gravity="center_horizontal" />-->
<TextView
android:id="#+id/register_guest_main_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginTop="15dp"
android:layout_gravity="center"
android:letterSpacing="0.01"
android:textAllCaps="true"
android:text="#string/register_guest"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:textColor="#de000000"
android:textSize="17sp"
android:textStyle="normal"
/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#color/white"
android:fitsSystemWindows="true"
android:layout_marginBottom="65dp">
<RelativeLayout
android:id="#+id/register_visitor_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:clickable="false"
android:fillViewport="true">
<LinearLayout
android:id="#+id/main_register_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:id="#+id/my_location"
style="#style/Headline2LeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:textAppearance="#style/TextAppearance.Text.Chronicle"
android:textSize="28sp"
tools:text="#string/five_thirty_fifth_ave" />
<TextView
style="#style/Body1RegRightRed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/my_location"
android:layout_alignParentEnd="true"
android:layout_marginEnd="#dimen/activity_horizontal_margin"
android:layout_toEndOf="#+id/my_location"
android:text="#string/location_change"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginTop="24dp"
android:gravity="center_vertical"
android:layout_marginBottom="8dp"
android:weightSum="2">
<TextView
android:id="#+id/select_date_and_time"
android:layout_width="wrap_content"
android:textSize="17sp"
android:lineSpacingExtra="6sp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textColor="#color/black"
android:text="#string/select_date_and_time"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:weightSum="2">
<TextView
android:id="#+id/register_guest_start_date"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="#string/register_guest_start_date"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
<TextView
android:id="#+id/register_guest_start_time"
style="#style/Body1RegRightBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:text="#string/register_guest_start_time"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:weightSum="2">
<TextView
android:id="#+id/register_guest_end_date"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="#string/register_guest_end_date"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular"
android:visibility="invisible" />
<TextView
android:id="#+id/register_guest_end_time"
style="#style/Body1RegRightBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:text="#string/register_guest_end_time"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor" />
<TextView
android:id="#+id/build_your_guest_list"
android:layout_width="wrap_content"
android:textSize="17sp"
android:layout_marginTop="42dp"
android:lineSpacingExtra="6sp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textColor="#color/black"
android:text="#string/build_your_guest_list"
android:paddingBottom="8dp"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="44dp"
android:id="#+id/add_guest"
android:layout_marginTop="3dp"
android:layout_marginBottom="8dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="44dp"
android:lineHeight="22sp"
android:drawablePadding="10dp"
android:drawableStart="#drawable/ic_add_24px"
android:drawableTint="#color/bluish"
android:layout_marginStart="17dp"
android:lineSpacingExtra="6sp"
android:textColor="#color/bluish"
android:gravity="center_vertical"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:text="#string/add_a_new_guest"
android:textSize="17sp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/registerUserSeparatorColor"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="44dp"
android:id="#+id/search_guest"
android:layout_marginTop="3dp"
android:visibility="gone"
android:layout_marginBottom="8dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="44dp"
android:lineHeight="22sp"
android:drawablePadding="10dp"
android:drawableStart="#drawable/ic_search_24px"
android:drawableTint="#color/bluish"
android:layout_marginStart="17dp"
android:lineSpacingExtra="6sp"
android:textColor="#color/bluish"
android:gravity="center_vertical"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:text="#string/search_past_guests"
android:textSize="17sp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
android:id="#+id/search_guest_line"
android:background="#color/registerUserSeparatorColor"
/>
<android.support.v7.widget.RecyclerView
android:id="#+id/guest_item_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#null"
android:overScrollMode="never"
tools:listitem="#layout/item_guest" />
<TextView
android:id="#+id/arrival_notifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="58dp"
android:letterSpacing="0.01"
android:lineSpacingExtra="4sp"
android:text="#string/arrival_notifications"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="normal"
android:visibility="invisible" />
<RelativeLayout
android:id="#+id/text_message_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:visibility="gone">
<TextView
android:id="#+id/text_message"
style="#style/Body1RegLeftBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
android:text="#string/text_message"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
<TextView
android:id="#+id/tap_phone_number_text"
style="#style/Body2RegLeftGrey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text_message"
android:layout_marginTop="2dp"
android:text="#string/tap_to_add_a_phone_number"
android:textAppearance="#style/TextAppearance.Text.Roboto.Regular" />
<android.support.v7.widget.SwitchCompat
android:id="#+id/text_message_switch"
style="#style/Color1SwitchStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginTop="11dp"
android:background="#color/settingsSeparatorLineColor"
android:visibility="gone" />
</LinearLayout>
<!-- <TextView
android:id="#+id/submit_users_btn"
style="#style/LoginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingBottom="30dp"
android:letterSpacing="0.07"
android:lineSpacingExtra="0sp"
android:text="#string/submit_visitor_list"
android:textAppearance="#style/TextAppearance.Text.Roboto.Medium"
android:textSize="16sp"
android:textStyle="normal" /> -->
</RelativeLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_gravity="center|bottom"
android:background="#color/transparent"
android:layout_marginBottom="75dp"
android:orientation="vertical"
android:id="#+id/fixedSubmitButtonlayout">
<TextView
android:id="#+id/submit_users_btn"
android:textColor="#757575"
android:textAlignment="center"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/textview_border"
android:letterSpacing="0.07"
android:gravity="center"
android:lineSpacingExtra="0sp"
android:text="#string/register_guest_caps"
android:textAppearance="#style/TextAppearance.Text.RidleyGrotesk.Regular"
android:textSize="16sp"
android:textStyle="normal" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
From the code above, the layout I am trying to fix at the bottom has id is: android:id="#+id/fixedSubmitButtonlayout".
I want it to stay intact/fixed at the bottom of the screen irrespective of the scrollview above it which is supposed to scroll behind it ( it does as of now, just the button position changes as the scroll view content overflows screen size). any ideas on how to fix this?
Just need to do this steps:
add a RelativeLayout as a Parent of CoordinatorLayout and
take out the last LinearLayout from CoordinatorLayout and
add it to RelativeLayout with android:layout_alignParentBottom="true".
note that you need to add android:layout_marginBottom="40dp" to your CoordinatorLayout
You can try this (tested and it works fine):
<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="match_parent"
>
<your CoordinatorLayout>
</your CoordinatorLayout>
<LinearLayout
android:id="#+id/fixedSubmitButtonlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="center|bottom"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/transparent"
android:orientation="vertical"
>
<TextView
android:id="#+id/submit_users_btn"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#drawable/textview_border"
android:gravity="center"
android:letterSpacing="0.07"
android:lineSpacingExtra="0sp"
android:text="#string/register_guest_caps"
android:textAlignment="center"
android:textAppearance="#style/TextAppearance.Text.RidleyGrotesk.Regular"
android:textColor="#757575"
android:textSize="16sp"
android:textStyle="normal"
/>
</LinearLayout>
</RelativeLayout>
It will work better in Relative layout
android:layout_alignParentBottom="true"
In your CoordinatorLayout, your View must be a direct child and not a child of another View inside the CoordinatorLayout. Then you can add this line of code to it:
android:layout_gravity="bottom"
The structure can be like this:
- CoordinatorLayout //(Parent View)
- - AppBarLayout //(Child View - Toolbar)
- - NestedScrollView //(Child View - Scrollable Content)
- - LinearLayout //(Child View - Bottom Fixed Content)
Here's a Sample code how it's supposed to be:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black_overlay"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/Toolbar.Light"
app:contentInsetStartWithNavigation="0dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--Your Scrollable Content Goes Here-->
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<!--Your Fixed Bottom Content Goes Here-->
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

How to show image in the place of creating message in androidX..?

I am creating an offlline SMS app.In that I have to place the option of selecting an image button and after selecting image I want to place it at the position of sending image.But do not understand how to adjust the imageView button to get desired layout.Someone can help me..?
I have searched a lot but found nothing.
XML FILE
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:padding="5dp"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="horizontal" tools:ignore="MissingConstraints" android:id="#+id/linearLayout">
<ImageView
android:id="#+id/inbox_thumb"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/circle"/>
<TextView
android:hint="Phone Number"
android:layout_width="5dp"
android:layout_marginTop="6dp"
android:padding="10dp"
android:textStyle="bold"
android:textSize="15dp"
android:gravity="left"
android:layout_height="wrap_content" android:id="#+id/phone" android:layout_weight="1"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView android:layout_width="384dp"
android:layout_height="661dp"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:id="#+id/reyclerview_message_list"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout">
</androidx.recyclerview.widget.RecyclerView>
<View android:layout_width="0dp"
android:layout_height="2dp"
tools:ignore="MissingConstraints"
android:background="#color/colorPrimaryDark"
android:layout_marginBottom="0dp"
app:layout_constraintBottom_toTopOf="#+id/message_area"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
</View>
<LinearLayout android:layout_width="0dp" android:layout_height="wrap_content"
android:id="#+id/message_area"
android:orientation="horizontal"
android:minHeight="48dp"
android:background="#ffffff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
tools:ignore="MissingConstraints">
<Button
android:text="attach img"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/btn1"
/>
<EditText
android:id="#+id/txtMessage"
android:hint="Enter message"
android:background="#android:color/transparent"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:maxLines="6"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content" app:srcCompat="#mipmap/ic_launcher" android:id="#+id/imageView2"
android:layout_weight="1"/>
<Button
android:id="#+id/btnSend"
android:text="SEND"
android:textSize="14dp"
android:clickable="true"
android:layout_width="64dp"
android:layout_height="48dp"
android:gravity="center"
android:layout_gravity="bottom" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Expected
Actual
I have created a basic template using your Layout in AndroidX. You can beautify it using your style, icons and colors accordingly. Please copy it and look at it in your Android Studio.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="horizontal"
android:padding="5dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/inbox_thumb"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/ic_launcher" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/phone"
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_weight="1"
android:gravity="left"
android:hint="Phone Number"
android:padding="10dp"
android:textSize="15dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/message_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="#drawable/rounded_rect_shape"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<androidx.appcompat.widget.AppCompatImageButton
android:id="#+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:src="#drawable/ic_launcher" />
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:cardBackgroundColor="#android:color/darker_gray"
app:cardCornerRadius="6dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#mipmap/ic_launcher" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/txtMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="#android:color/transparent"
android:hint="Enter message"
android:maxLines="6" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center"
android:text="SEND"
android:textSize="14dp" />
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="2dp"
android:layout_marginBottom="0dp"
android:background="#color/colorPrimaryDark"
app:layout_constraintBottom_toTopOf="#+id/message_area"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/reyclerview_message_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:scrollbarAlwaysDrawVerticalTrack="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="#id/message_area"
app:layout_constraintTop_toBottomOf="#+id/linearLayout"/>
If I understand correctly, you're trying to place the "imageView2" ImageView on top of the "txtMessage" EditText, is that right?
If that's how it is, what you need to do is wrap both of them in a vertical LinearLayout, like so:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/txtMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:background="#android:color/transparent"
android:hint="Enter message"
android:maxLines="6" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#mipmap/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="8dp">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/circle_drawable"
android:backgroundTint="#android:color/black"
android:padding="8dp"
android:layout_margin="8dp"
android:src="#drawable/ic_add_black_24dp"
android:tint="#android:color/white" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="#android:color/darker_gray"
app:cardCornerRadius="6dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:src="#mipmap/ic_launcher" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
android:weightSum="1">
<EditText
android:id="#+id/et1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toStartOf="#+id/ib2"
android:layout_margin="8dp"
android:text="Hello" />
<ImageButton
android:id="#+id/ib2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/circle_drawable"
android:backgroundTint="#android:color/black"
android:padding="8dp"
android:layout_margin="8dp"
android:layout_alignParentEnd="true"
android:src="#drawable/ic_send_black_24dp"
android:tint="#android:color/white" />
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
I have used background drawable, you can replace with your add and send image.
Hope it solves your problem.

Categories

Resources