Is there a way to scroll behind the keyboard on Android? - 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>

Related

CardView not fully Scrollable on my fragment

I am using a fragment to display cardview and a common Bottomnavigation for all fragments. Here I have more than 5 cards as per my data but I am not able to scroll to see all cards. only scrollable up to the second card and the second one is also not fully visible due to the bottom navigation.
main_activity.xml
<?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"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff293353"
android:paddingTop="20dp">
<fragment
android:id="#+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_above="#id/nav_view"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="#navigation/mobile_navigation" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="#drawable/bottom_tab_style"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/bottom_nav_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
Then Recycleview
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_height="wrap_content"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:weightSum="1"
android:layout_marginStart="70dp"
android:layout_marginEnd="70dp"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:background="#drawable/left_enabled"
android:layout_weight="0.5"
android:textAlignment="center"
android:id="#+id/btn_normal"
android:text="#string/normal"
android:textColor="#color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/btn_cognitive"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="#drawable/right_disabled"
android:gravity="center"
android:text="#string/cognitive"
android:textAlignment="center"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:layout_height="wrap_content">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</ScrollView>
Then cardview content
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:background="#drawable/cardstyle"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
>
<com.google.android.material.card.MaterialCardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/transparent"
card_view:cardBackgroundColor="#color/transparent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
card_view:cardCornerRadius="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="2dp"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3f4865"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
>
<TextView
android:id="#+id/txt_recordTitle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/poppins"
android:paddingStart="12dp"
android:text="Normal Test 01"
android:gravity="center_vertical"
android:textColor="#color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="10dp"
android:src="#drawable/ic_card_walk" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/parameter1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins"
android:letterSpacing="0.12"
android:text="No: of gait cycles"
android:textColor="#cecece"
android:textSize="12sp" />
<TextView
android:id="#+id/p1_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins"
android:letterSpacing="0.16"
android:text="Details"
android:textColor="#FFF"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="10dp"
android:src="#drawable/ic_card_walk" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/parameter2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins"
android:letterSpacing="0.12"
android:text="Stride Length"
android:textColor="#cecece"
android:textSize="12sp" />
<TextView
android:id="#+id/p2_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins"
android:letterSpacing="0.16"
android:text="Details"
android:textColor="#FFF"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="10dp"
android:src="#drawable/ic_card_walk" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/parameter3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins"
android:letterSpacing="0.12"
android:text=" Gait time"
android:textColor="#cecece"
android:textSize="12sp" />
<TextView
android:id="#+id/p3_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins"
android:letterSpacing="0.16"
android:text="p2"
android:textColor="#FFF"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="#drawable/info_button_style"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/total_n_gait_score"
android:textAlignment="center"
android:textColor="#FFF" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ProgressBar
android:id="#+id/card_progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:background="#drawable/circle_shape"
android:indeterminate="false"
android:max="100"
android:progress="65"
android:progressDrawable="#drawable/card_progress" />
<TextView
android:id="#+id/text_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="60%"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
android:textColor="#color/white" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:orientation="horizontal"
android:paddingBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:id="#+id/card_date"
android:text="date"
android:textColor="#FFF"
android:textSize="1sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:ellipsize="end"
android:maxLines="1"
android:text="time"
android:id="#+id/card_time"
android:textColor="#FFF"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Please check my code and help me with this.
This is wrong in your main_activity.xml for fragment android:layout_above="#id/nav_view", it is used for RelativeLayout. Instead use app:layout_constraintBottom_toTopOf="#id/nav_view". This will solve your second issue(the second one is also not fully visible due to the bottom navigation).
Change your ScrollView to NestedScrollView.
In your cardview content you don't need ConstraintLayout, LinearLayout is sufficient as root element (remove ConstraintLayout as you are not utilising its power of flat view hierarchy). And if your LinearLayout background can be moved to background for MaterialCardView then you don't need LinearLayout too.
For your recyclerview set the nestedScrollingEnabled to false either through xml or by code. Try these things, it will solve your problem.

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 set layout height fix in android?

I have created one layout in android. the issue I am facing is in some case there are two lines of description and in some cases there is only one line of description. and My layout height automatically adjust base on that. but I want to fix my layout height in every case. means my layout height should be equal in every case. Below is the XML code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_marginRight="3dp"
android:layout_marginLeft="3dp"
android:layout_marginBottom="3dp">
<androidx.cardview.widget.CardView
android:layout_height="wrap_content"
android:layout_width="300dp"
app:cardCornerRadius="4dp"
app:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/notificationTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:maxLines="1"
android:text="Title"
android:textSize="18sp"/>
<TextView
android:id="#+id/notificationDescription"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Description"
android:layout_marginBottom="4dp"
android:maxLines="2"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#f2f2f2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".3"
android:orientation="vertical">
<TextView
android:id="#+id/notificationDealPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:text="Deal Price"
android:textColor="#3691e9"
android:textSize="16sp" />
<TextView
android:id="#+id/notificationActualPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/notificationDealPrice"
android:text="Actual Price"
android:background="#drawable/strike_thru"
android:textColor="#757575"
android:textSize="16sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center"
android:layout_weight=".3"
android:orientation="vertical">
<TextView
android:id="#+id/notificationDiscountPercentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10% OFF"
android:textAlignment="center"
android:textColor="#color/colorPrimary"
android:textSize="18dp"
android:textStyle="bold"
android:visibility="visible" />
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#f2f2f2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="72"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Coupon Code" />
<TextView
android:id="#+id/notificationCouponCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:gravity="center"
android:singleLine="true"
android:text="Not Required"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="#308fe9"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#f2f2f2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="72"
android:orientation="vertical">
<Button
android:id="#+id/notificationUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GET DEAL"
android:background="#78ca28"
android:textColor="#fff"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
Image attached for the better understanding of the problem.
enter image description here
You can add in the description TextView this attribute: android:minLines="2"

add an horizontal line and some icon with text in bottom like facebook

I want add a footer to a cardview.
my current XML layout in RecyclerView is this:
(this xml code act as row in RecyclerView )
code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="#dimen/activity_margin_half"
app:cardBackgroundColor="#color/placeholder_grey"
app:cardCornerRadius="6dp"
app:cardPreventCornerOverlap="false">
<ProgressBar
android:id="#+id/movie_progress"
style="#style/Widget.AppCompat.ProgressBar"
android:layout_width="#dimen/activity_margin"
android:layout_height="#dimen/activity_margin"
android:layout_gravity="center"
android:theme="#style/CircularProgress"/>
<ImageView
android:id="#+id/movie_poster"
android:layout_width="#dimen/poster_thumb_width"
android:layout_height="#dimen/poster_thumb_height"/>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_marginTop="#dimen/activity_margin"
android:background="#drawable/bg_round_rect"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_margin"
android:paddingEnd="#dimen/activity_margin"
android:paddingLeft="#dimen/poster_thumb_width"
android:paddingRight="#dimen/activity_margin"
android:paddingStart="#dimen/poster_thumb_width"
android:paddingTop="#dimen/activity_margin_half">
<TextView
android:id="#+id/movie_year"
style="#style/TextAppearance.AppCompat.Caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_margin_content"
android:layout_marginStart="#dimen/activity_margin_content"
android:alpha="0.38"
android:gravity="start"
android:maxLines="1"
android:textStyle="bold"
android:textColor="#f14e4e"
tools:text="2009 | EN"/>
<TextView
android:id="#+id/movie_title"
style="#style/TextAppearance.AppCompat.Subhead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_margin_content"
android:layout_marginStart="#dimen/activity_margin_content"
android:layout_marginTop="#dimen/activity_margin_quarter"
android:textColor="#9b92b3"
android:maxLines="1"
tools:text="Movie Title"/>
<TextView
android:id="#+id/movie_desc"
style="#style/TextAppearance.AppCompat.Caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/activity_margin_content"
android:layout_marginStart="#dimen/activity_margin_content"
android:layout_marginTop="#dimen/activity_margin_half"
android:ellipsize="end"
android:maxLines="2"
android:textColor="#9b92b3"
tools:text="Nowadays, user engagement is considered one of the most important metrics for the success of your app"/>
</LinearLayout>
</FrameLayout>
Now I want add more thing to this code.
I want add an horizontal line. (I think I must View) and some Icon with text like this picture:
how can I do that?
I have designed two XML for two different CardView. See the attached image for output. Hope this will help you~
Facebook like CardView with Image, Title and Some Text:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="2dp"
card_view:cardUseCompatPadding="false" >
<!-- Content -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="88dp">
<!-- Thumbnail :: Image-->
<ImageView
android:id="#+id/image_thumbnail"
android:layout_width="100dp"
android:layout_height="110dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:scaleType="centerCrop"
android:src="#mipmap/ic_launcher"/>
<!-- Two-Line TextView -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/image_thumbnail"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<TextView
android:id="#+id/text_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="16dp"
android:layout_marginRight="8dp"
android:maxLines="2"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#000000"
android:text="This is a title"/>
<TextView
android:id="#+id/text_subtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/text_title"
android:layout_marginTop="4dp"
android:maxLines="2"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:textSize="14sp"
android:textColor="#000000"
android:text="Here is Some text" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
OUTPUT:
Facebook like CardView with Image, Title, Some Text and Like, Comment, Share actions:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="2dp"
card_view:cardUseCompatPadding="false" >
<!-- Content -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="88dp">
<!-- Thumbnail :: Image-->
<ImageView
android:id="#+id/image_thumbnail"
android:layout_width="100dp"
android:layout_height="110dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:scaleType="centerCrop"
android:src="#mipmap/ic_launcher"/>
<!-- Two-Line TextView -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/image_thumbnail"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<TextView
android:id="#+id/text_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="16dp"
android:layout_marginRight="8dp"
android:maxLines="2"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#000000"
android:text="This is a title"/>
<TextView
android:id="#+id/text_subtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/text_title"
android:layout_marginTop="4dp"
android:maxLines="2"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:textSize="14sp"
android:textColor="#727272"
android:text="Here is Some text" />
</RelativeLayout>
<!-- Bottom line with actions -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#id/image_thumbnail">
<!-- Horizontal line -->
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#ababab">
</View>
<!-- Like + Comment + Share -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:weightSum="4">
<!-- Like -->
<LinearLayout
android:id="#+id/layout_like"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_like"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:textSize="16sp"
android:textColor="#727272"
android:text="Like"
android:textStyle="bold"/>
</LinearLayout>
<!-- Comment -->
<LinearLayout
android:id="#+id/layout_comment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.6"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:gravity="center_vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_comment"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:textSize="16sp"
android:textColor="#727272"
android:text="Comment"
android:textStyle="bold"/>
</LinearLayout>
<!-- Share -->
<LinearLayout
android:id="#+id/layout_share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="16dp"
android:gravity="center_vertical|right">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_share"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="sans-serif"
android:textSize="16sp"
android:textColor="#727272"
android:text="Share"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
OUTPUT:
Add a view like this below the cardView
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/black"/>
then use LinearLayout/RelativeLayout below it to hold the icons and text
please try this.... hope can help
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:layout_width="80dp"
android:layout_height="80dp">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:src="#drawable/ic_launcher"
android:layout_height="match_parent" />
</FrameLayout>
<android.support.v4.widget.Space
android:layout_width="24dp"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Title"/>
<Space
android:layout_width="match_parent"
android:layout_height="8dp" />
<TextView
android:id="#+id/some_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="some text"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:padding="4dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:drawableLeft="#drawable/ic_launcher"
android:text="Like"
/>
</FrameLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#android:color/black"/>
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:padding="4dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:drawableLeft="#drawable/ic_launcher"
android:text="Like"
/>
</FrameLayout>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#android:color/black"/>
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:padding="4dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:drawableLeft="#drawable/ic_launcher"
android:text="Like"
/>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Button under recyclerview is not visible

I'm progrmming app with RecyclerView and bottom buttons. RecyclerView is filling by images, that I got from the server. Top bar is fixed
http://joxi.ru/KAxee4XTEMpPr8
RecyclerView code
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
RecyclerView is filling by ImageViews
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:scaleType="centerCrop"
android:layout_marginBottom="1dp"
android:layout_marginEnd="1dp"
android:layout_marginStart="1dp"
android:layout_marginTop="1dp" />
Buttons code that invisible
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<ru.noorsoft.rubkoff.HeButton
android:id="#+id/button1"
style="#style/leftButStyle"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_weight="1"
android:gravity="center"
android:textAllCaps="false"
android:textColor="#color/colorBlue"
android:textSize="20sp" />
<ru.noorsoft.rubkoff.HeButton
android:id="#+id/button2"
android:background="#android:color/transparent"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_weight="1"
android:textColor="#color/colorBlue"
android:textAllCaps="false"
android:textSize="20sp" />
<ru.noorsoft.rubkoff.HeButton
android:id="#+id/button3"
style="#style/rightButStyle"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_weight="1"
android:textColor="#color/colorBlue"
android:textAllCaps="false"
android:textSize="20sp" />
</LinearLayout>
<?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"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- here goes the header -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="header"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="#android:layout/simple_gallery_item"
android:layout_below="#id/header"
android:clipToPadding="false"
android:paddingBottom="55dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="3">
<ru.noorsoft.rubkoff.HeButton
android:id="#+id/button1"
style="#style/leftButStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textAllCaps="false"
android:textColor="#color/colorBlue"
android:textSize="20sp" />
<ru.noorsoft.rubkoff.HeButton
android:id="#+id/button2"
android:background="#android:color/transparent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:textColor="#color/colorBlue"
android:textAllCaps="false"
android:textSize="20sp" />
<ru.noorsoft.rubkoff.HeButton
android:id="#+id/button3"
style="#style/rightButStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:textColor="#color/colorBlue"
android:textAllCaps="false"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
I solved that in another way. I gave a PaddingBottom in RecyclerView calculating the Size of the Button. For example, if total size of button is 40 dp, I gave PaddingBottom 50dp. That's why, Button is not overlap with RecyclerView
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:background="#color/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.fragment.tutorPanel.tutorProfile.quiz.TestFragment">
<androidx.cardview.widget.CardView
android:id="#+id/timer_cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:cardCornerRadius="12dp"
app:cardElevation="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/_5sdp"
android:orientation="vertical">
<TextView
android:id="#+id/test_title_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Paper 03"
android:textSize="13dp"
android:textColor="#color/colorAccent"
android:fontFamily="#font/inter_semi_bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/time_remaining_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="#drawable/ic_clock"
android:drawablePadding="5dp"
android:text="Time Remaining"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/test_title_textView" />
<TextView
android:id="#+id/time_remaining_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="05:00"
android:textSize="20dp"
android:textColor="#color/colorAccent"
android:fontFamily="#font/inter_semi_bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/time_remaining_textView"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/question_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:paddingBottom="55dp"
android:layout_below="#+id/timer_cardView"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="5"
tools:listitem="#layout/item_question" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:paddingTop="7dp"
android:paddingBottom="7dp"
android:gravity="center"
android:background="#drawable/login_sign_up_button_state"
android:text="Submit Answer"
android:textColor="#color/white"
android:textSize="15dp"
android:fontFamily="#font/inter_semi_bold"/>
</RelativeLayout>
Here width of TextView is (15+10+7+7) ~ 40dp. So I gave PaddingBottom 50dp in RecyclerView

Categories

Resources