Error in using Recycler View and Scroll View together? - java

I have been facing issue using Recycler View and Scroll View together in the same bottom navigation activity in different tabs. I am hiding one of the view by using Visibility Gone in the java file.
I tried many solutions but nothing worked till now so I am posting here if someone can help me figure it out.
<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="match_parent"
tools:context="com.cartoonswikipedia.www.familyconnect.Main2Activity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="60dp"
android:layout_marginBottom="60dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/postrecycler"
android:layout_width="368dp"
android:layout_height="312dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#color/colorPrimaryDark">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/toolbar_subtitle"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="left"
android:paddingLeft="10dp"
android:text="#string/app_name"
android:textColor="#FFFFFF"
android:textSize="30dp"
android:textStyle="bold" />
<ImageView
android:id="#+id/profileimagee45"
android:layout_width="69dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="right"
android:clickable="true"
android:onClick="hi"
android:padding="12dp"
app:srcCompat="#drawable/c" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollview"
android:layout_marginTop="60dp"
android:layout_marginBottom="60dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<TableLayout
android:id="#+id/abc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TextView
android:id="#+id/editemail"
android:layout_width="262dp"
android:layout_height="37dp"
android:textAppearance="#style/TextAppearance.AppCompat.Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.113" />
<ImageView
android:id="#+id/profileimage"
android:layout_width="87dp"
android:layout_height="88dp"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:onClick="proimg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.167"
android:clickable="false"/>
<EditText
android:id="#+id/editname"
android:layout_width="262dp"
android:layout_height="50dp"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.338" />
<LinearLayout
android:id="#+id/abcdef"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/children"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Children"
android:textSize="25dp"/>
<ImageView
android:id="#+id/adddd"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</LinearLayout>
<EditText
android:id="#+id/editheight"
android:layout_width="262dp"
android:layout_height="50dp"
android:ems="10"
android:hint="Height in CM"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.338" />
<EditText
android:id="#+id/editweight"
android:layout_width="262dp"
android:layout_height="50dp"
android:ems="10"
android:hint="Weight in KG"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.338" />
<RelativeLayout>
<TextView
android:id="#+id/blood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="11dp"
android:layout_marginStart="11dp"
android:text="Blood Group"
android:textSize="25dp" />
</RelativeLayout>
<RelativeLayout>
<TextView
android:id="#+id/religion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="11dp"
android:layout_marginStart="11dp"
android:text="Religion"
android:textSize="25dp" />
</RelativeLayout>
<Button
android:id="#+id/editprofile"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:background="#000000"
android:onClick="edit"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Save Profile"
android:textColor="#ffffff" />
<Button
android:id="#+id/logout"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:background="#000000"
android:onClick="logout"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Log Out"
android:textColor="#ffffff"
android:textSize="15dp"
android:textStyle="bold"/>
</TableLayout>
</ScrollView>
<ProgressBar
android:id="#+id/empty_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.473"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.464" />
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_marginTop="60dp"
android:layout_marginBottom="60dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:theme="#style/AppTheme"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/navigation" />

Related

Soft Keyboard overlaps Edit text field. Tried all the generic solutions

I have tried all the solutions i.e adding adjustPan and adjustResize in manifest.xml adding fitsSystem window true nd all that the soft keyboard still overlaps Here is my code for better context.
Xml for items in recycler view
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="0dp"
android:layout_marginBottom="6dp"
android:fitsSystemWindows="true"
>
<LinearLayout
android:id="#+id/layout_question"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1"
android:fitsSystemWindows="true">
<TextView
android:id="#+id/question_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:padding="#dimen/dimen_10_dp"
android:paddingLeft="#dimen/dimen_5_dp"
android:layout_marginEnd="#dimen/dimen_5_dp"
tools:text="Q1)"
android:layout_marginStart="#dimen/dimen_5_dp"
android:textColor="#000000"
android:fontFamily="#font/work_sans_semibold"
android:textSize="17sp"
/>
<TextView
android:id="#+id/tv_question"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/dimen_5_dp"
android:layout_marginEnd="#dimen/dimen_5_dp"
android:layout_weight="0.4"
android:lineSpacingExtra="9dp"
android:padding="5dp"
android:paddingLeft="#dimen/dimen_5_dp"
android:text="#{questionName}"
android:textColor="#000000"
android:fontFamily="#font/work_sans_light"
android:textSize="22sp"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="9dp"
android:layout_marginTop="5dp"
android:orientation="horizontal"
app:visibleGone="#{isSubjectiveMarks}">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_marginStart="30dp"
android:background="#drawable/bg_border_edittext"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="#+id/et_marks"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="#dimen/dimen_5_dp"
android:layout_marginEnd="#dimen/dimen_5_dp"
android:background="#drawable/bg_border_edittext"
android:fontFamily="sans-serif"
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:maxLength="4"
android:overScrollMode="always"
android:padding="3dp"
android:textColor="#000"
android:textSize="29sp" />
</LinearLayout>
<TextView
android:id="#+id/tv_total_marks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginEnd="24dp"
android:fontFamily="#font/work_sans"
android:gravity="end|right"
android:padding="#dimen/dimen_10_dp"
android:text="#{`Out of ` + totalMarks}"
android:textColor="#4D89EB"
android:textSize="17sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:visibleGone="#{isSubjectiveMarks}"
tools:text="Outof 10" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_question"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/subjective_hint_text"
android:orientation="vertical"
app:visibleGone="#{isSubjective}">
<EditText
android:id="#+id/et_question"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_marginStart="#dimen/dimen_15_dp"
android:layout_marginEnd="#dimen/dimen_15_dp"
android:enabled="#{isViewMode}"
android:gravity="top|start"
android:imeOptions="actionSend|flagNoEnterAction"
android:inputType="textMultiLine"
android:maxLength="3000"
android:background="#drawable/desc_answer_bg"
android:fontFamily="#font/work_sans"
android:textColor="#202124"
android:textSize="21sp"
android:overScrollMode="always"
android:padding="10dp"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:singleLine="false"
android:text="#={subjectiveAnswerText}"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</com.google.android.material.textfield.TextInputLayout>
<RadioGroup
android:id="#+id/rg_answer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/dimen_5_dp"
android:paddingTop="0dp"
android:layout_marginTop="0dp"
android:clickable="#{isViewMode}"
app:listToRadioGroup="#{optionDataWithAnswer}"
app:visibleGone="#{isObjective}"
/>
<LinearLayout
android:id="#+id/ll_cb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/dimen_5_dp"
android:orientation="vertical"
android:paddingTop="10dp"
app:visibleGone="#{isMultiSelect}" />
<EditText
android:id="#+id/et_sub_obj"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/dimen_5_dp"
android:fontFamily="sans-serif"
android:gravity="left"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLength="3000"
android:overScrollMode="always"
android:padding="5dp"
app:visibleGone="#{isSubjectiveObjectiveTrueOption}"
tools:text="enter text here.." />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/objective_remarks_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
app:visibleGone="#{isObjectiveWithRemarks}"
>
<RadioGroup
android:id="#+id/rg_objective_with_remarks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/dimen_5_dp"
android:clickable="#{isViewMode}"
android:paddingTop="0dp"
android:layout_marginTop="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:listToRadioGroup="#{optionDataWithAnswer}" />
<Switch
android:id="#+id/toggle_objective_remarks_textbox"
android:layout_width="0dp"
android:paddingTop="2dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/add_remarks"
android:paddingEnd="#dimen/dimen_10_dp"
android:paddingStart="#dimen/dimen_10_dp"
android:textSize="17sp"
android:fontFamily="#font/work_sans"
android:switchPadding="#dimen/dimen_15_dp"
android:gravity="end"
android:textOn="#string/on"
android:textOff="#string/off"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/rg_objective_with_remarks"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarStyle="outsideInset"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toggle_objective_remarks_textbox"
>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/objective_remarks_field_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:hint="#string/enter_remarks"
app:counterMaxLength="200"
app:counterEnabled="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toggle_objective_remarks_textbox">
<EditText
android:id="#+id/objective_remarks_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/dimen_15_dp"
android:layout_marginEnd="#dimen/dimen_15_dp"
android:minHeight="100dp"
android:minLines="3"
android:autofillHints="Enter Remarks"
android:background="#drawable/desc_answer_bg"
android:enabled="#{isViewMode}"
android:fontFamily="#font/work_sans"
android:gravity="top|start"
android:imeOptions="actionDone"
android:inputType="textMultiLine|textShortMessage"
android:maxLength="200"
android:overScrollMode="always"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#202124"
android:textSize="21sp" />
</com.google.android.material.textfield.TextInputLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
app:visibleGone="#{isMultiSelectWithRemarks}"
>
<LinearLayout
android:id="#+id/layout_multiselect_remarks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/dimen_5_dp"
android:orientation="vertical"
android:paddingTop="10dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Switch
android:id="#+id/toggle_multiselect_remarks_textbox"
android:layout_width="0dp"
android:paddingTop="2dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/add_remarks"
android:textSize="17sp"
android:fontFamily="#font/work_sans"
android:switchPadding="#dimen/dimen_15_dp"
android:gravity="end"
android:paddingEnd="#dimen/dimen_10_dp"
android:paddingStart="#dimen/dimen_10_dp"
android:textOn="#string/on"
android:textOff="#string/off"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/layout_multiselect_remarks"
/>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/multiselect_remarks_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/enter_remarks"
app:counterEnabled="true"
app:counterMaxLength="200"
android:visibility="gone"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toggle_multiselect_remarks_textbox"
>
<EditText
android:id="#+id/multiselect_remarks_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/dimen_15_dp"
android:layout_marginEnd="#dimen/dimen_15_dp"
android:padding="10dp"
android:minHeight="100dp"
android:minLines="3"
android:background="#drawable/desc_answer_bg"
android:enabled="#{isViewMode}"
android:overScrollMode="always"
android:fontFamily="#font/work_sans"
android:gravity="top|start"
android:imeOptions="actionDone"
android:inputType="textMultiLine|textShortMessage"
android:textAppearance="?android:attr/textAppearanceMedium"
android:maxLength="200"
android:textColor="#202124"
android:textSize="21sp"
android:autofillHints="Enter Remarks" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/short_answer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/dimen_10_dp"
android:hint="#string/enter_short_answer"
android:orientation="vertical"
android:textColor="#000"
app:visibleGone="#{isShortAnswer}"
>
<EditText
android:id="#+id/short_answer_et_question"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="#dimen/dimen_15_dp"
android:layout_marginEnd="#dimen/dimen_15_dp"
android:enabled="#{isViewMode}"
android:gravity="top|start"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLength="1000"
android:background="#drawable/desc_answer_bg"
android:fontFamily="#font/work_sans"
android:textColor="#202124"
android:textSize="21sp"
android:overScrollMode="always"
android:padding="#dimen/dimen_10_dp"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:singleLine="false"
android:text="#={shortAnswerText}"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
</com.google.android.material.textfield.TextInputLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="#dimen/dimen_5_dp"
app:visibleGone="#{isDate}"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="10dp"
android:paddingVertical="20dp"
android:layout_marginHorizontal="#dimen/dimen_15_dp"
android:orientation="horizontal"
android:background="#drawable/calendar_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/date_text_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="28dp"
android:hint="#string/choose_a_date"
android:fontFamily="#font/work_sans"
android:text="#={DateText}"
android:textSize="21sp"
android:textColor="#000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/calendar_image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/calendar_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_marginStart="#dimen/dimen_15_dp"
android:layout_marginEnd="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_baseline_calendar_today_24"
android:focusable="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="8dp"
android:layout_marginTop="5dp"
android:orientation="horizontal"
app:visibleGone="#{isMarksWithRemarks}">
<LinearLayout
android:id="#+id/marks_with_remarks_linearLayout"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_marginStart="34dp"
android:background="#drawable/bg_border_edittext"
android:gravity="center"
android:textColor="#000"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="#+id/et_marks_remarks"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="#dimen/dimen_5_dp"
android:layout_marginEnd="#dimen/dimen_5_dp"
android:background="#drawable/bg_border_edittext"
android:fontFamily="sans-serif"
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:maxLength="4"
android:overScrollMode="always"
android:padding="3dp"
android:textColor="#000"
android:textSize="29sp" />
</LinearLayout>
<TextView
android:id="#+id/tv_total_marks_remarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginEnd="24dp"
android:layout_marginBottom="18dp"
android:fontFamily="#font/work_sans"
android:gravity="end|right"
android:padding="#dimen/dimen_10_dp"
android:text="#{`Out of ` + totalMarks}"
android:textColor="#4D89EB"
android:textSize="17sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/marks_text_input_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:visibleGone="#{isMarksWithRemarks}"
tools:text="Outof 10" />
<Switch
android:id="#+id/toggle_marks_remarks_textbox"
android:layout_width="0dp"
android:paddingTop="2dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/add_remarks"
android:textSize="17sp"
android:paddingEnd="#dimen/dimen_10_dp"
android:paddingStart="#dimen/dimen_10_dp"
android:gravity="end"
android:fontFamily="#font/work_sans"
android:switchPadding="#dimen/dimen_15_dp"
android:textOn="#string/on"
android:textOff="#string/off"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/marks_with_remarks_linearLayout"
</LinearLayout>
</androidx.cardview.widget.CardView>
Fragment class
Java
Objects.requireNonNull(getActivity()).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
also added attributes in manifest file
<activity android:name=".view.AssessmentActivity"
android:theme="#style/AppTheme.NoActionBar"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
/>
Here I have two solutions. They might be helpful for you.
android:windowSoftInputMode="adjustResize|stateHidden"
or
Simply adding this to the parent layout:
android:fitsSystemWindows="true"

RecyclerView not scrolling inside NestedScrollView

I'm designing a complex UI that has a NestedScrollView as a parent and inside it, there is a RecyclerView. Now the problem is that I'm not able to scroll the items inside the RecyclerView.
Things I've tried
Replacing ScrollView with NestedScrollView
Enabling android:fillViewport="true"
Disabling NestedScrolling of RecyclerView
<?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=".screens.StudentPreview">
<androidx.cardview.widget.CardView
android:id="#+id/toolbarCV"
android:layout_width="match_parent"
android:layout_height="130dp"
android:translationY="-45dp"
app:cardCornerRadius="30dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1641A2">
<ImageView
android:id="#+id/menuIV"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_gravity="center"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:src="#drawable/ic_home"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.7" />
<TextView
android:id="#+id/featureName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:fontFamily="#font/poppins_light"
android:text="Student Preview"
android:textColor="#fff"
android:textSize="22sp"
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.75" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.core.widget.NestedScrollView
android:id="#+id/studentPreviewNSV"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="90dp"
android:fillViewport="true"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="#+id/avatarCV"
android:layout_width="60dp"
android:layout_height="60dp"
app:cardBackgroundColor="#color/colorPrimaryDark"
app:cardCornerRadius="40dp"
app:cardElevation="0dp"
app:layout_constraintBottom_toBottomOf="#+id/studentDetailsCL"
app:layout_constraintEnd_toStartOf="#+id/studentDetailsCL"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/studentDetailsCL">
<ImageView
android:id="#+id/avatarIV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:visibility="gone"
tools:src="#drawable/avatar_sample" />
<TextView
android:id="#+id/nameInitialTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/montserrat"
android:textColor="#FFF"
android:textSize="24sp"
android:textStyle="bold"
android:visibility="gone"
tools:text="AK"
tools:visibility="visible" />
</androidx.cardview.widget.CardView>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/studentDetailsCL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/avatarCV"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/studentNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/montserrat"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Akrit Khanna" />
<TextView
android:id="#+id/classNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/montserrat"
android:textColor="#000"
android:textSize="15sp"
app:layout_constraintStart_toStartOf="#+id/studentNameTV"
app:layout_constraintTop_toBottomOf="#+id/studentNameTV"
tools:text="Class 8th A" />
<TextView
android:id="#+id/lastLoggedTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:fontFamily="#font/raleway"
android:textColor="#000"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="#+id/classNameTV"
app:layout_constraintTop_toBottomOf="#+id/classNameTV"
tools:text="Last Logged: 30-01-2020" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:id="#+id/classEnrollCV"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
app:cardBackgroundColor="#F5F5F5"
app:cardCornerRadius="18dp"
app:cardElevation="3dp"
app:layout_constraintEnd_toStartOf="#+id/courseEnrollCV"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/detailsGL">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/classEnrollCountTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/raleway"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/classEnrollTVContainerFL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="1" />
<FrameLayout
android:id="#+id/classEnrollTVContainerFL"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#D0D9EC"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/raleway"
android:text="Classes Enrolled"
android:textColor="#1641A2"
android:textSize="18sp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/courseEnrollCV"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:cardBackgroundColor="#F5F5F5"
app:cardCornerRadius="18dp"
app:cardElevation="3dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/classEnrollCV"
app:layout_constraintTop_toTopOf="#+id/detailsGL">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/courseEnrollCountTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/raleway"
android:textColor="#000"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/courseEnrollTVContainerFL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="1" />
<FrameLayout
android:id="#+id/courseEnrollTVContainerFL"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#D0D9EC"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/raleway"
android:text="Courses Enrolled"
android:textColor="#1641A2"
android:textSize="18sp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/detailsGL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="90dp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/reportCL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#F5F5F5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/classEnrollCV">
<Spinner
android:id="#+id/classOrTermSpinner"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintEnd_toStartOf="#+id/courseSpinner"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="#+id/courseSpinner"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/classOrTermSpinner"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/reportRV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/courseSpinner" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Use a NestedScrolView and add this to your RecyclerView:
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setHasFixedSize(false);
Or this to the XML:
android:nestedScrollingEnabled="false"
Also it might help to add orientation to the recyclerView:
android:orientation="vertical"
Wrap all the views present inside NestedScrollView into a RelativeLayout. For ex,
<androidx.core.widget.NestedScrollView
android:id="#+id/studentPreviewNSV"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="90dp"
android:fillViewport="true"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- your remaining code -->
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
I managed to fix this problem by adding android:layout_marginBottom="100dp"
I think this was happening because I gave android:layout_marginTop="90dp" to my NestedScrollView and due to that RecyclerView was assuming that all the items are visible on the screen so there is no need for scrolling. (Correct me if I'm wrong)
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/reportRV"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/courseSpinner"
tools:listitem="#layout/report_list_layout"
android:orientation="vertical"
android:layout_marginBottom="100dp"/>

Textview over Imageview in a fixed position

I would like to put some textviews over an image in a fixed position.
I tried using relative, contraint and frame layout but what I see in preview does not match on my device.
I tried to use px, sp and dp but it did not help.
Textviews must stay exactly in their position on every device.
Thanks
screen device and android studio layout
xml CODE ADDED:
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".b_command">
<RadioGroup
android:id="#+id/radioGroup_conn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="#+id/plancia_img"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<RadioButton
android:id="#+id/radioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="USB" />
<RadioButton
android:id="#+id/radioButton2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ethernet" />
</RadioGroup>
<RadioGroup
android:id="#+id/Radiogroup_cmd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/radioGroup_conn">
<RadioButton
android:id="#+id/radioButton3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Note on/off" />
<RadioButton
android:id="#+id/radioButton4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Prog Change" />
<RadioButton
android:id="#+id/radioButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Ctrl Change" />
</RadioGroup>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/plancia_layout"
android:layout_width="363dp"
android:layout_height="225dp"
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/Radiogroup_cmd">
<ImageView
android:id="#+id/plancia_img"
android:layout_width="363dp"
android:layout_height="225dp"
android:contentDescription="TODO"
android:scaleType="centerCrop"
android:src="#drawable/plancia"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="50dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
android:layout_marginTop="50dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="17dp"
android:layout_marginTop="160dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_yellow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="102dp"
android:layout_marginTop="160dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="265dp"
android:layout_marginTop="160dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_f1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="165dp"
android:layout_marginTop="75dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_f2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="215dp"
android:layout_marginTop="75dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_f3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="265dp"
android:layout_marginTop="75dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/val_f4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="315dp"
android:layout_marginTop="75dp"
android:background="#FFFFFF"
android:backgroundTint="#F8F5F5"
android:gravity="center"
android:padding="2dp"
android:text="#string/basic_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
you can try screen height programmatic to your textview according to your requirement for more detailing answer elaborate your question first.
If I were you, I would use a custom view in which I would simply calculate the necessary coordinates.
https://www.vogella.com/tutorials/AndroidCustomViews/article.html

"ScrollView can only host 1 child" in 2 fragments with only 1 child?

I have 2 fragments, each with a ScrollView, and 1 ConstraintLayout inside. The ContraintLayout contains multiple children inside, but the ScrollViews only have 1 child. When I go to fragment 1, I recieve no error. I go to fragment 2, all good. When I return to fragment 1 however, I get the following error:
2020-03-20 22:56:20.491 7887-7887/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.starenkysoftware.vanshapp, PID: 7887
java.lang.IllegalStateException: ScrollView can host only one direct child
at android.widget.ScrollView.addView(ScrollView.java:266)
at com.google.android.material.snackbar.BaseTransientBottomBar.showView(BaseTransientBottomBar.java:719)
at com.google.android.material.snackbar.BaseTransientBottomBar$1.handleMessage(BaseTransientBottomBar.java:243)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I do not understand how this is possible, as I do not add anything else within the layout while switching
EDIT: Added code
Fragment 1:
<?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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/recipient_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Beneficiary"
android:textStyle="bold"
android:textSize="15sp"
android:textColor="#color/colorPrimary"
android:layout_marginTop="20dp"
android:layout_marginLeft="18dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
<View
android:id="#+id/recipient_splitter"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="3dp"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:background="#color/colorPrimary"
app:layout_constraintTop_toBottomOf="#id/recipient_header"/>
<!-- Recipient Name Fields -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/recipient_first_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
app:layout_constraintHorizontal_chainStyle="spread"
android:layout_marginRight="10dp"
app:layout_constraintTop_toBottomOf="#id/recipient_splitter"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#id/recipient_middle_name"
android:hint="First Name">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/first_name_field"
android:inputType="textPersonName"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/recipient_middle_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintTop_toBottomOf="#id/recipient_splitter"
app:layout_constraintLeft_toRightOf="#id/recipient_first_name"
app:layout_constraintRight_toLeftOf="#id/recipient_last_name"
android:hint="Middle Name">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/middle_name_field"
android:inputType="textPersonName"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/recipient_last_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="20dp"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/recipient_first_name"
app:layout_constraintBottom_toBottomOf="#+id/recipient_first_name"
app:layout_constraintLeft_toRightOf="#id/recipient_middle_name"
android:hint="Last Name">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/last_name_field"
android:inputType="textPersonName"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- Recipient Location Field -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/recipient_state"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
app:layout_constraintHorizontal_chainStyle="spread"
android:layout_marginRight="10dp"
app:layout_constraintTop_toBottomOf="#id/recipient_first_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#id/recipient_city"
android:hint="Province">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/state_field"
android:inputType="textPersonName"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/recipient_city"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="20dp"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/recipient_state"
app:layout_constraintBottom_toBottomOf="#+id/recipient_state"
app:layout_constraintLeft_toRightOf="#id/recipient_state"
android:hint="City">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/city_field"
android:inputType="textPersonName"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- Phone Number -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/phone_number_layout"
app:prefixText=""
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:layout_constraintTop_toBottomOf="#id/recipient_state"
android:hint="Phone Number">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/phone_number_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- Transger Info Section -->
<TextView
android:id="#+id/transfer_info_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Transfer Info"
android:textStyle="bold"
android:textSize="15sp"
android:textColor="#color/colorPrimary"
android:layout_marginTop="25dp"
android:layout_marginLeft="18dp"
app:layout_constraintTop_toBottomOf="#id/phone_number_layout"
app:layout_constraintLeft_toLeftOf="parent"/>
<View
android:id="#+id/transfer_info_splitter"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="3dp"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:background="#color/colorPrimary"
app:layout_constraintTop_toBottomOf="#id/transfer_info_header"/>
<!-- SOF (Source of Fund -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/sof_layout"
app:prefixText=""
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:layout_constraintTop_toBottomOf="#id/transfer_info_splitter"
android:hint="Source of Fund">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/sof_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- Type of Transfer Dropdown -->
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:id="#+id/type_of_transfer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Type"
app:layout_constraintTop_toBottomOf="#id/sof_layout">
<AutoCompleteTextView
android:id="#+id/type_of_transfer_dropdown"
android:editable="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/btb_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#id/type_of_transfer_layout">
<!-- Bank Name -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/bank_name_layout"
app:prefixText=""
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:layout_constraintTop_toTopOf="parent"
android:hint="Bank Name">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/bank_name_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- Phone Number -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/bank_account_number_layout"
app:prefixText=""
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:layout_constraintTop_toBottomOf="#id/bank_name_layout"
android:hint="Bank Account Number">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/bank_account_number_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"/>
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Currency Selector -->
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:id="#+id/currency_selector_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:layout_constraintBottom_toBottomOf="#id/amount_layout"
app:layout_constraintTop_toTopOf="#id/amount_layout"
app:layout_constraintLeft_toLeftOf="parent">
<AutoCompleteTextView
android:id="#+id/currency_dropdown"
android:editable="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- Amount Field -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/amount_layout"
app:prefixText=""
app:suffixText="CAD"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginLeft="35dp"
android:layout_marginRight="20dp"
app:layout_constraintTop_toBottomOf="#id/btb_info"
app:layout_constraintLeft_toRightOf="#id/currency_selector_layout"
android:hint="Amount">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/amount_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/currency_rate_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text=""
android:textSize="13sp"
app:layout_constraintBottom_toTopOf="#+id/photo_checkbox"
app:layout_constraintLeft_toLeftOf="#+id/amount_layout"
app:layout_constraintTop_toBottomOf="#id/amount_layout" />
<com.google.android.material.button.MaterialButton
android:id="#+id/submit_button"
style="#style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:text="Send"
app:layout_constraintTop_toBottomOf="#+id/amount_layout"
app:layout_constraintRight_toRightOf="parent"/>
<com.google.android.material.button.MaterialButton
android:id="#+id/photo_button"
style="#style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:text="Photo Verification"
app:layout_constraintTop_toBottomOf="#+id/amount_layout"
app:layout_constraintLeft_toLeftOf="parent"/>
<CheckBox
android:id="#+id/photo_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:clickable="false"
app:layout_constraintBottom_toBottomOf="#id/photo_button"
app:layout_constraintLeft_toRightOf="#id/photo_button"
app:layout_constraintTop_toTopOf="#+id/photo_button"/>
<View
android:layout_width="match_parent"
android:layout_height="30dp"
app:layout_constraintTop_toBottomOf="#id/submit_button"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
Fragment 2:
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/previous_transfer_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="Previous 5 Transfers"
android:gravity="center"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialCardView1"
style="#style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/mtrl_card_spacing"
android:layout_marginRight="#dimen/mtrl_card_spacing"
android:layout_marginTop="15dp"
android:minHeight="100dp"
app:cardBackgroundColor="#ffffff"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/previous_transfer_title">
<TextView
android:id="#+id/transfer_card_1_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:text="Exchange Rate"
android:textColor="#878787"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:background="#color/colorPrimary" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialCardView2"
style="#style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/mtrl_card_spacing"
android:layout_marginRight="#dimen/mtrl_card_spacing"
android:layout_marginTop="20dp"
android:minHeight="100dp"
app:cardBackgroundColor="#ffffff"
app:layout_constraintTop_toBottomOf="#+id/materialCardView1">
<TextView
android:id="#+id/transfer_card_2_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:text="Exchange Rate"
android:textColor="#878787"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:background="#color/colorPrimary" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialCardView3"
style="#style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/mtrl_card_spacing"
android:layout_marginRight="#dimen/mtrl_card_spacing"
android:layout_marginTop="20dp"
android:minHeight="100dp"
app:cardBackgroundColor="#ffffff"
app:layout_constraintTop_toBottomOf="#+id/materialCardView2">
<TextView
android:id="#+id/transfer_card_3_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:text="Exchange Rate"
android:textColor="#878787"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:background="#color/colorPrimary" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialCardView4"
style="#style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/mtrl_card_spacing"
android:layout_marginRight="#dimen/mtrl_card_spacing"
android:layout_marginTop="20dp"
android:minHeight="100dp"
app:cardBackgroundColor="#ffffff"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/materialCardView3">
<TextView
android:id="#+id/transfer_card_4_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:text="Exchange Rate"
android:textColor="#878787"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:background="#color/colorPrimary" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/materialCardView5"
style="#style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/mtrl_card_spacing"
android:layout_marginRight="#dimen/mtrl_card_spacing"
android:layout_marginTop="20dp"
android:layout_marginBottom="15dp"
android:minHeight="100dp"
app:cardBackgroundColor="#ffffff"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/materialCardView4"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:id="#+id/transfer_card_5_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:text="Exchange Rate"
android:textColor="#878787"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="bottom"
android:background="#color/colorPrimary" />
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
I had snackbars that attatched to items. They worked perfectly under some circumstances, but for some reason not always. I think this may have something to do with how Fragments are created and destroyed upon exit.
I replaced my snackbars with toasts, and it fixed the issue, although the appearance has been worsened.

ListView Scrollbar is not resizing

I went through different solutions from stackoverflow and web, but didn't work. the scrollbar of listView is very tiny, I want it to be large enough. I used android:scrollbarSize="55dip" but it didn't work, android ignores it.
activity_main.xml :
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="368dp"
android:layout_height="47dp"
android:layout_gravity="end"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText">
<RadioButton
android:id="#+id/azadRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_weight="1"
android:gravity="right"
android:layoutDirection="rtl"
android:text="آزاد"
android:textSize="30sp" />
<RadioButton
android:id="#+id/qafiaRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_weight="1"
android:gravity="right"
android:layoutDirection="rtl"
android:text="قافیہ"
android:textSize="30sp" />
<RadioButton
android:id="#+id/sabiqaRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_weight="1"
android:gravity="right"
android:layoutDirection="rtl"
android:text="سابقہ"
android:textSize="30sp" />
</RadioGroup>
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:layout_marginTop="36dp"
android:ems="10"
android:inputType="text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="8dp"
android:onClick="Finder"
android:text="Finder"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.555"
app:layout_constraintStart_toEndOf="#+id/editText"
app:layout_constraintTop_toTopOf="parent" />
<ListView
android:id="#+id/listView"
android:layout_width="359dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="44dp"
android:scrollbars="vertical"
android:verticalScrollbarPosition="left"
android:scrollbarSize="55dip"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/radioGroup" />
</android.support.constraint.ConstraintLayout>
custom.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:paddingRight="40dp"
android:scrollbarSize="55dip"
android:textSize="20px" android:paddingTop="10dip" android:paddingBottom="10dip"/>
</LinearLayout>
Use this line too with the scrollsize you used:
android:scrollbarThumbVertical="#color/colorPrimaryDark"

Categories

Resources