Putting a label on the top-right corner - android

I'm trying to put a "New" label inside my layout located on the right of my cardview:
I didn't get any preview in Android Studio: the layout is displayed but the content is not displayed maybe because there a constraint that avoid the text to be displayed.
Do you see any mistake in my layout ?
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
app:cardElevation="2dp"
app:cardCornerRadius="4dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/img"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:contentDescription="#string/img_desc"
android:src="#mipmap/ic_launcher"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="#+id/img"
android:layout_centerVertical="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="#color/cardview_head"
android:textSize="16sp"
android:textStyle="bold"
tools:text="test" />
<TextView
android:id="#+id/labelNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/new_label"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:text="#string/new_label"
android:textColor="#color/white"
android:textSize="12sp"
tools:text="New" />
</LinearLayout>
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="#color/cardview_subhead"
tools:text="test" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>

Using ConstraintLayout
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/img"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="10dp"
android:contentDescription="#string/app_name"
android:src="#mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.77" />
<TextView
android:id="#+id/text1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#FFC107"
android:ellipsize="end"
android:maxLines="1"
android:padding="10dp"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/labelNew"
app:layout_constraintEnd_toStartOf="#+id/text2"
app:layout_constraintStart_toEndOf="#+id/img"
app:layout_constraintTop_toTopOf="parent"
tools:text="test" />
<TextView
android:id="#+id/labelNew"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#00BCD4"
android:ellipsize="end"
android:maxLines="1"
android:padding="10dp"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/text1"
app:layout_constraintStart_toStartOf="#+id/text1"
app:layout_constraintTop_toBottomOf="#+id/text1"
tools:text="New" />
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="#E91E63"
android:ellipsize="end"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.77"
tools:text="test" />
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="#FFC107"
android:ellipsize="end"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="#+id/labelNew"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.77"
tools:text="test" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
OUTPUT
Try this way
<?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:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:id="#+id/img"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="16dp"
android:contentDescription="#string/img_desc"
android:src="#mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="#color/cardview_head"
android:textSize="16sp"
android:textStyle="bold"
tools:text="test" />
<TextView
android:id="#+id/labelNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/new_label"
android:ellipsize="end"
android:maxLines="1"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:text="#string/new_label"
android:textColor="#color/white"
android:textSize="12sp"
tools:text="New" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="#color/cardview_subhead"
tools:text="test" />
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="#color/cardview_subhead"
tools:text="A day ago" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
OUTPUT

Related

Android Edittext error area's arrow not poining to the error icon

I am attaching a screenshot to show you what's going on.
As we can see there is a red arrow coming from error area and it is not poining to the error icon on EditText area. I hope you understand what I mean. How to solve that?
Here is my layout.
fragment_credentials_register.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="pl.jawegiel.wordsbyassociations.viewmodel.ViewModelCredentialsRegister" />
</data>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/rl_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="#+id/ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:weightSum="10"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/input_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
app:layout_constraintLeft_toLeftOf="parent">
<EditText
android:id="#+id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="name"
android:ems="10"
android:hint="#string/username"
android:inputType="textPersonName"
android:textColor="#FFFFFF" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="5">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<EditText
android:id="#+id/et_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="email"
android:ems="10"
android:hint="email"
android:inputType="textEmailAddress"
android:textColor="#FFFFFF" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="10"
android:layout_below="#id/ll"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_marginEnd="3dp"
android:layout_weight="5">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/input_pass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginRight="3dp"
android:layout_marginEnd="3dp"
android:layout_marginTop="10dp"
>
<EditText
android:id="#+id/et_pass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="#string/password"
android:ems="10"
android:hint="#string/password"
android:inputType="textPassword"
android:textColor="#FFFFFF" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginStart="3dp"
android:layout_weight="5">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/input_pass_con"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginStart="3dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/et_pass_confirmation"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:autofillHints="pass_confirmation"
android:ems="10"
android:hint="pass_confirmation"
android:inputType="textPassword"
android:textColor="#FFFFFF" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<CheckBox
android:id="#+id/cb_terms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="i_declare"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rl_main" />
<TextView
android:id="#+id/tv_terms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:text="terms_and_conditions2"
android:textColor="#0080ff"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#+id/cb_terms"
app:layout_constraintStart_toEndOf="#+id/cb_terms"
app:layout_constraintTop_toBottomOf="#+id/rl_main" />
<Button
android:id="#+id/b_registration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:enabled="false"
android:text="#string/register"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_terms" />
<TextView
android:id="#+id/tv_registration_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:text=""
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/b_registration" />
<ProgressBar
android:id="#+id/pb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/b_registration" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</layout>
Is there anything you need more?
Thank you in advance!

Recycler view items auto wrapping inside scrollview

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

ellipsize not working in ConstraintLayout

I need cut TextView 'name', like a "Nameeeeee...". I use ellipsize but it doesn't work.
Screenshot
I think, i need attach right side of TextView 'name', but i dont known to whom.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="#color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/photo"
app:civ_circle_background_color="#CCC"
android:layout_width="63dp"
android:layout_height="74dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/avatars" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:text="Nameeeeeeeeeeeeeeeeeeeee"
android:ellipsize="end"
android:maxLines="1"
android:lines="1"
android:textSize="20sp"
app:layout_constraintStart_toEndOf="#+id/photo"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="#+id/daysToBirthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="7dp"
android:text="daysToBirthday"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#+id/birthday"
app:layout_constraintTop_toBottomOf="#+id/birthday" />
<TextView
android:id="#+id/birthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="birthday"
app:layout_constraintStart_toStartOf="#+id/name"
app:layout_constraintTop_toBottomOf="#+id/name" />
<TextView
android:id="#+id/age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="age"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="#+id/birthday"
app:layout_constraintEnd_toEndOf="#+id/ageName"
app:layout_constraintStart_toStartOf="#+id/ageName"
app:layout_constraintTop_toTopOf="#+id/birthday" />
<TextView
android:id="#+id/ageName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:text="AgeName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Your TextView ellipsize is not working because you didn't mention it's end constraint.
These are changes required:
As you can see it should end to the start of TextView which id is ageName.
Width must be 0dp which is match_constraint for TextView
Replace your TextView with this one below`
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:text="Nameeeeeeeeeeeeeeeeeeeee"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="#id/ageName"
app:layout_constraintStart_toEndOf="#+id/photo"
app:layout_constraintTop_toTopOf="parent" />
Please check if this suits your needs.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="#color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/photo"
app:civ_circle_background_color="#CCC"
android:layout_width="63dp"
android:layout_height="74dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="#tools:sample/avatars" />
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:maxLines="1"
android:lines="1"
android:textSize="#dimen/dp_20"
android:text="Nameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
android:ellipsize="end"
app:layout_constraintStart_toEndOf="#+id/photo"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toStartOf="#id/ageName"
/>
<TextView
android:id="#+id/daysToBirthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="7dp"
android:text="daysToBirthday"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#+id/birthday"
app:layout_constraintTop_toBottomOf="#+id/birthday" />
<TextView
android:id="#+id/birthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="birthday"
app:layout_constraintStart_toStartOf="#+id/name"
app:layout_constraintTop_toBottomOf="#+id/name" />
<TextView
android:id="#+id/age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="age"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="#+id/birthday"
app:layout_constraintEnd_toEndOf="#+id/ageName"
app:layout_constraintStart_toStartOf="#+id/ageName"
app:layout_constraintTop_toTopOf="#+id/birthday" />
<TextView
android:id="#+id/ageName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:text="AgeName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
In your name TextView i changed android:layout_width="wrap_content" to android:layout_width="0dp".
Moreover i have also added this attribute app:layout_constraintEnd_toStartOf="#id/ageName".
Add the following elements to '#id/name' and also constrain it to the 'ageName':
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:scrollHorizontally="true"
android:singleLine="true"

Android: The bottom navigation view is blocking out part of my content in my ScrollView

The problem I have is that the bottom navigation bar is blocking the bottom part of my content in the ScrollView. I have tried to change the android:layout_height of the ScrollView to wrap_content instead of match_parent and it did resolve that issue, but it presented me with another. Now, the top part of my ScrollView is cut off from the display. Is there anyway to resolve both? I am using constraint layout as my parent layout of the activity.
Below is my xml code of the activity.
<?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=".MainActivity"
android:orientation="vertical"
android:background="#color/colorBackground">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/dash_bottomNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:backgroundTint="#color/colorWhite"
app:menu="#menu/menu_bottom_navigation"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="#+id/dash_bottomNavigation"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
tools:layout_editor_absoluteX="2dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/dash_headerImg"
android:layout_width="match_parent"
android:layout_height="260dp"
android:contentDescription="#string/app_name"
android:scaleType="centerCrop"
android:src="#drawable/header_background"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#40000000"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="#id/dash_headerImg"/>
<ImageView
android:id="#+id/dash_ic_menu"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="16dp"
android:layout_marginStart="18dp"
android:contentDescription="#string/app_name"
android:src="#drawable/dashboard_ic_menu"
android:background="#drawable/dashboard_menu_background"
android:padding="7dp"
android:tint="#color/colorWhite"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="#+id/dash_welcomeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome back!"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:textColor="#color/colorWhite"
android:textSize="23sp"
android:textStyle="bold"
app:layout_constraintTop_toBottomOf="#+id/dash_ic_menu"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:background="#drawable/searchbar_background"
android:gravity="center_vertical"
android:padding="4dp"
app:layout_constraintTop_toBottomOf="#+id/dash_welcomeText">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginStart="10dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="6dp"
android:contentDescription="#string/app_name"
android:src="#drawable/ic_search_black_24dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="10dp"
android:background="#null"
android:gravity="center_vertical"
android:imeOptions="actionSearch"
android:inputType="text"
tools:ignore="Autofill"
android:textColor="#color/colorPrimaryText"
android:textSize="18sp"
android:hint="Search"/>
</LinearLayout>
<View
android:id="#+id/dash_viewSupporter"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_marginBottom="50dp"
app:layout_constraintBottom_toBottomOf="#+id/dash_headerImg"
app:layout_constraintStart_toStartOf="parent"/>
<androidx.cardview.widget.CardView
android:id="#+id/dash_runTrackerCard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="10dp"
app:cardBackgroundColor="#color/colorWhite"
app:cardCornerRadius="8dp"
app:layout_constraintEnd_toStartOf="#+id/dash_calorieTrackerCard"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dash_viewSupporter">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:scaleX="0.7"
android:scaleY="0.7"
android:contentDescription="#string/app_name"
android:src="#drawable/run"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Run tracker"
android:textColor="#color/colorPrimaryText"
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/dash_calorieTrackerCard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="25dp"
android:layout_marginStart="10dp"
app:cardBackgroundColor="#color/colorWhite"
app:cardCornerRadius="8dp"
app:layout_constraintStart_toEndOf="#+id/dash_runTrackerCard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dash_viewSupporter">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:scaleX="0.7"
android:scaleY="0.7"
android:contentDescription="#string/app_name"
android:src="#drawable/calorie_tracker"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Calorie tracker"
android:textColor="#color/colorPrimaryText"
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/dash_meditationCard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginTop="25dp"
android:layout_marginBottom="25dp"
android:layout_marginEnd="10dp"
app:cardBackgroundColor="#color/colorWhite"
app:cardCornerRadius="8dp"
app:layout_constraintVertical_bias="0"
app:layout_constraintEnd_toStartOf="#+id/dash_dietCard"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dash_runTrackerCard">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:contentDescription="#string/app_name"
android:scaleX="0.7"
android:scaleY="0.7"
android:src="#drawable/yoga" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Meditation"
android:textColor="#color/colorPrimaryText"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/dash_dietCard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginStart="10dp"
app:cardBackgroundColor="#color/colorWhite"
app:cardCornerRadius="8dp"
app:layout_constraintVertical_bias="0"
app:layout_constraintStart_toEndOf="#+id/dash_meditationCard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dash_calorieTrackerCard">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="15dp">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:scaleX="0.7"
android:scaleY="0.7"
android:contentDescription="#string/app_name"
android:src="#drawable/diet"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Diet"
android:textColor="#color/colorPrimaryText"
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<RelativeLayout
android:id="#+id/dash_fitnessView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
app:layout_constraintTop_toBottomOf="#+id/dash_meditationCard"
app:layout_constraintBottom_toBottomOf="parent"
android:background="#color/banner_background_light">
<LinearLayout
android:id="#+id/dash_fitnessBannerLayout"
android:layout_width="170dp"
android:layout_height="280dp"
android:layout_margin="10dp"
android:background="#color/banner_background"
android:orientation="vertical">
<TextView
android:id="#+id/dash_fitnessViewAllText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="5dp"
android:text="View all" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="50dp"
android:text="Fitness LifeStyle"
android:textAllCaps="true"
android:textColor="#011a27"
android:textSize="25sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Embark on your fitness journey now" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:paddingLeft="10dp"
android:text="From: bornfitness.com" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/dash_fitnessRecycler"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_toEndOf="#+id/dash_fitnessBannerLayout"
android:background="#fcfdfe" />
<ProgressBar
android:id="#+id/dash_fitnessProgressBar"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:layout_toEndOf="#+id/dash_fitnessBannerLayout"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Screenshot of my design view of the activity:
Just make android:layout_height="0dp" in Scrollview.
And Please use NestedScrollView if you have Recyclerview inside Scoll
your Scrollview like this :
<ScrollView
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/dash_bottomNavigation"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
tools:layout_editor_absoluteX="2dp">
</ScrollView>

Issue with constraint layout

I'm having a considerable issue that I haven't encountered before. I did what I normally do working with constraints. Not all of my fields will fit on the screen. It shows up fine running on an external tablet. Below is my activitymain. I've also ran it in linear and relative layout. I can Any help would be appreciated.
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlack"
tools:context=".MainActivity">
<Spinner
android:id="#+id/spCompany"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="468dp"
android:background="#color/colorWhite"
android:gravity="center"
android:spinnerMode="dropdown"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rnumberText" />
<TextView
android:id="#+id/densityText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:background="#color/colorWhite"
android:text=""
android:visibility="gone"
app:layout_constraintBottom_toTopOf="#id/strainerLabel"
app:layout_constraintTop_toBottomOf="#+id/spCompany" />
<TextView
android:id="#+id/strainerLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text="#string/strainer"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/strainerText"
app:layout_constraintTop_toBottomOf="#+id/spCompany" />
<TextView
android:id="#+id/strainerText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text=""
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/spRatio"
app:layout_constraintTop_toBottomOf="#+id/strainerLabel" />
<Spinner
android:id="#+id/spRatio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:spinnerMode="dropdown"
app:layout_constraintBottom_toTopOf="#+id/enterweightLabel"
app:layout_constraintTop_toBottomOf="#+id/strainerText" />
<TextView
android:id="#+id/rnumberText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:background="#color/colorWhite"
android:text=""
android:visibility="gone"
app:layout_constraintBottom_toTopOf="#+id/spCompany"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="spread_inside" />
<TextView
android:id="#+id/catdensityText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:text=""
app:layout_constraintBottom_toBottomOf="#+id/spRatio"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spRatio" />
<TextView
android:id="#+id/enterweightLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text="#string/enter_weight"
android:textAlignment="center"
android:textStyle="bold"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/weightInput"
app:layout_constraintTop_toBottomOf="#+id/spRatio" />
<EditText
android:id="#+id/weightInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:autofillHints="Enter Weight"
android:background="#color/colorWhite"
android:clickable="true"
android:ems="10"
android:focusable="true"
android:gravity="center"
android:imeOptions="actionDone"
android:importantForAutofill="yes"
android:inputType="numberDecimal"
android:singleLine="true"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/totalcatLabel"
app:layout_constraintTop_toBottomOf="#+id/enterweightLabel"
tools:targetApi="o" />
<TextView
android:id="#+id/totalcatLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text="#string/total_catalyst"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/totalcatText"
app:layout_constraintTop_toBottomOf="#+id/weightInput" />
<TextView
android:id="#+id/totalcatText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:background="#color/colorWhite"
android:clickable="false"
android:gravity="center"
android:text=""
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/totalweightLabel"
app:layout_constraintTop_toBottomOf="#+id/totalcatLabel" />
<TextView
android:id="#+id/totalweightLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text="#string/total_weight"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/totalweightText"
app:layout_constraintTop_toBottomOf="#+id/totalcatText" />
<TextView
android:id="#+id/totalweightText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center_horizontal|center_vertical"
android:text=""
android:textSize="60sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/calcButton"
app:layout_constraintTop_toBottomOf="#+id/totalweightLabel" />
<Button
android:id="#+id/calcButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:clickable="true"
android:focusable="true"
android:text="#string/calculate"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/clearButton"
app:layout_constraintTop_toBottomOf="#+id/totalweightText" />
<Button
android:id="#+id/clearButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:clickable="true"
android:focusable="true"
android:text="#string/Clear"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/calcButton" />
</android.support.constraint.ConstraintLayout>
You can put your ConstraintLayout inside a ScrollView
Yeah, your content takes more room than the available then your view overflows the device. Using a ScrollView will solve you problem with short screens.
This is how looks like:
<?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="wrap_content"
android:id="#+id/root">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorBlack"
tools:context=".MainActivity">
<Spinner
android:id="#+id/spCompany"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="468dp"
android:background="#color/colorWhite"
android:gravity="center"
android:spinnerMode="dropdown"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rnumberText" />
<TextView
android:id="#+id/densityText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="7dp"
android:background="#color/colorWhite"
android:text=""
android:visibility="gone"
app:layout_constraintBottom_toTopOf="#id/strainerLabel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spCompany" />
<TextView
android:id="#+id/strainerLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text="#string/strainer"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/strainerText"
app:layout_constraintTop_toBottomOf="#+id/spCompany" />
<TextView
android:id="#+id/strainerText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text=""
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/spRatio"
app:layout_constraintTop_toBottomOf="#+id/strainerLabel" />
<Spinner
android:id="#+id/spRatio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:spinnerMode="dropdown"
app:layout_constraintBottom_toTopOf="#+id/enterweightLabel"
app:layout_constraintTop_toBottomOf="#+id/strainerText" />
<TextView
android:id="#+id/rnumberText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:background="#color/colorWhite"
android:text=""
android:visibility="gone"
app:layout_constraintBottom_toTopOf="#+id/spCompany"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="spread_inside" />
<TextView
android:id="#+id/catdensityText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:text=""
app:layout_constraintBottom_toBottomOf="#+id/spRatio"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spRatio" />
<TextView
android:id="#+id/enterweightLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text="#string/enter_weight"
android:textAlignment="center"
android:textStyle="bold"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/weightInput"
app:layout_constraintTop_toBottomOf="#+id/spRatio" />
<EditText
android:id="#+id/weightInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:autofillHints="Enter Weight"
android:background="#color/colorWhite"
android:clickable="true"
android:ems="10"
android:focusable="true"
android:gravity="center"
android:imeOptions="actionDone"
android:importantForAutofill="yes"
android:inputType="numberDecimal"
android:singleLine="true"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/totalcatLabel"
app:layout_constraintTop_toBottomOf="#+id/enterweightLabel"
tools:targetApi="o" />
<TextView
android:id="#+id/totalcatLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text="#string/total_catalyst"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/totalcatText"
app:layout_constraintTop_toBottomOf="#+id/weightInput" />
<TextView
android:id="#+id/totalcatText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:background="#color/colorWhite"
android:clickable="false"
android:gravity="center"
android:text=""
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/totalweightLabel"
app:layout_constraintTop_toBottomOf="#+id/totalcatLabel" />
<TextView
android:id="#+id/totalweightLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center"
android:text="#string/total_weight"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/totalweightText"
app:layout_constraintTop_toBottomOf="#+id/totalcatText" />
<TextView
android:id="#+id/totalweightText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:gravity="center_horizontal|center_vertical"
android:text=""
android:textSize="60sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/calcButton"
app:layout_constraintTop_toBottomOf="#+id/totalweightLabel" />
<Button
android:id="#+id/calcButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="#color/colorWhite"
android:clickable="true"
android:focusable="true"
android:text="#string/calculate"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/clearButton"
app:layout_constraintTop_toBottomOf="#+id/totalweightText" />
<Button
android:id="#+id/clearButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:clickable="true"
android:focusable="true"
android:text="#string/Clear"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="#+id/calcButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

Categories

Resources