How to adjust constraint layout to scroll view to fit all screen? - android

I have problem in the bottom layout where my constraint layout does not fill the scroll view entirely(blank space bellow). This is the image evidence of the problem.
In this case I want the gray background to fill that white space below. I tried match parent in everything but it does not work.
This is my xml file that belongs to the layout I uploaded
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout">
<data>
<variable
name="viewModel"
type="com.repsol.repsolmove.ui.login.LoginViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="#+id/scrolView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView"
android:layout_width="174dp"
android:layout_height="70dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="3dp"
android:src="#drawable/ic_img_logo_repsolmove"
app:layout_constraintBottom_toTopOf="#+id/imageBottomMargin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="#+id/login"
android:layout_width="0dp"
android:layout_height="105dp"
android:layout_marginTop="30dp"
app:errorText="#string/invalid_card_number"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/imageView"
app:titleText="#string/login_title" />
<com.repsol.repsolmove.ui.widgets.RepsolInputLayout
android:id="#+id/password"
android:layout_width="0dp"
android:layout_height="105dp"
app:errorText="#string/invalid_password"
app:isPassword="true"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/login"
app:titleText="#string/password_title" />
<TextView
android:id="#+id/newPassword"
style="#style/RepsolText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:fontFamily="#font/repsol_regular"
android:text="#string/new_password"
android:textSize="16dp"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintTop_toBottomOf="#+id/password" />
<Button
android:id="#+id/btnLogin"
android:layout_width="228dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:background="#drawable/shape_rounded_fill_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/login"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/newPassword" />
<Button
android:id="#+id/btnJoin"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="32dp"
android:background="#drawable/shape_rounded_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/join"
android:textAllCaps="false"
android:textColor="#color/colorPrimaryDark"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/btnNologin"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="#+id/marginStart"
app:layout_constraintTop_toBottomOf="#+id/btnLogin"
app:layout_constraintVertical_bias="0.75" />
<Button
android:id="#+id/btnNologin"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="32dp"
android:background="#drawable/shape_rounded_no_stroke_rectangle"
android:fontFamily="#font/repsol_regular"
android:text="#string/enter_without_login"
android:textAllCaps="false"
android:textColor="#color/colorPrimaryDark"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/marginEnd"
app:layout_constraintStart_toEndOf="#+id/btnJoin"
app:layout_constraintTop_toBottomOf="#+id/btnLogin"
app:layout_constraintVertical_bias="0.75" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/imageBottomMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.30" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/marginStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.10" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/marginEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.90" />
<com.repsol.repsolmove.ui.widgets.RepsolDialog
android:id="#+id/dialog"
android:layout_width="match_parent"
android:layout_height="0dp"
android:elevation="10dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<include
android:id="#+id/loading"
layout="#layout/loading"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

Add this attribute to your NestScrollView element in xml file
android:fillViewport="true"

Related

How do I properly push a layout upwards when using a Snackbar in Android?

I'm trying to implement a proper snackbar that doesn't overlap other views, to do that I added to the activity a Coordinator Layout and inside I placed a constraint layout with the views I want to be pushed up. In the constraint layout I set the attribute app:layout_dodgeInsetEdges="bottom" but when the snackbar appears it pushes the views upwards but it is a little glitchy, here is the video:
video
The video is of an emulator but the same thing happens on real phones.
<?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=".login.LoginActivity">
<ImageView
android:id="#+id/login_logo"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_marginStart="80dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="80dp"
android:contentDescription="#string/logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/google_logo" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/loginCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_outwire_logo">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/innerConstraintlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_dodgeInsetEdges="bottom">
<LinearLayout
android:id="#+id/create_account_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="16dp"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/facebook_sign_button">
<TextView
android:id="#+id/dont_have_account_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:text="#string/don_t_have_an_account"
android:textSize="#dimen/subTextSize" />
<TextView
android:id="#+id/create_account_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:text="#string/create_account"
android:textColor="#color/clickable_subtext_blue"
android:textSize="#dimen/subTextSize" />
</LinearLayout>
<EditText
android:id="#+id/login_user_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:autofillHints="Username, Email"
android:ems="14"
android:hint="#string/email_username"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="TextFields" />
<EditText
android:id="#+id/login_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autofillHints="Password"
android:ems="14"
android:hint="#string/password"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_user_email" />
<com.app.custom.views.SignInButton
android:id="#+id/sign_in_button"
android:layout_width="#dimen/sign_button_width"
android:layout_height="#dimen/sign_button_height"
android:layout_marginTop="48dp"
android:background="#drawable/sign_in_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_password"
app:text="#string/sign_in"
app:text_color="?attr/colorOnPrimary"
app:text_size="#dimen/sign_button_text" />
<TextView
android:id="#+id/forgot_password_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:clickable="true"
android:elevation="2dp"
android:focusable="true"
android:text="#string/forgot_your_password"
android:textColor="#color/clickable_subtext_blue"
android:textSize="#dimen/subTextSize"
app:layout_constraintEnd_toEndOf="#+id/login_password"
app:layout_constraintTop_toBottomOf="#+id/login_password" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/or_sign_in_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.6"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="#+id/google_sign_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/sign_in_button">
<View
android:id="#+id/separator"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/separator_grey"
android:contentDescription="#string/sign_in_options_separator"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/or_sign_in_with_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/or_sign_in_with_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/or_sign_in_with"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="#+id/separator2"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="#color/separator_grey"
android:contentDescription="#string/sign_in_options_separator"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/or_sign_in_with_text"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.app.custom.views.SignInButton
android:id="#+id/google_sign_button"
android:layout_width="#dimen/sign_button_width"
android:layout_height="#dimen/sign_button_height"
android:layout_marginTop="64dp"
android:backgroundTint="?attr/colorSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/sign_in_button"
app:src_logo="#drawable/google_logo"
app:text="#string/google"
app:text_color="?attr/colorOnSecondary" />
<com.app.custom.views.SignInButton
android:id="#+id/facebook_sign_button"
android:layout_width="#dimen/sign_button_width"
android:layout_height="#dimen/sign_button_height"
android:layout_marginTop="8dp"
android:backgroundTint="#color/facebook_blue"
android:clickable="true"
android:focusable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/google_sign_button"
app:src_logo="#drawable/fb_logo"
app:text="#string/facebook"
app:text_size="#dimen/sign_button_text"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

When using chain in ConstraintLayout an blank space appears on top and bottom

I am using ConstraintLayout in fragment.
When I create vertical chain with my views a blank spaces appear on top and bottom.
Without chain there is no blank spaces.
I am using:
com.google.android.material:material:1.1.0
androidx.constraintlayout:constraintlayout:2.0.0-beta5
Here is my layout of fragment is:
<layout 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">
<data>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".login.screens.login.LoginFragment"
>
<LinearLayout
android:id="#+id/tv_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/ic_ellipse_h284_w360"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="#+id/til_phone_number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome User!" />
</LinearLayout>
<EditText
android:id="#+id/til_phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_title"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:hint="Phone number"
android:inputType="phone"
app:layout_constraintBottom_toTopOf="#+id/til_password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_title" />
<EditText
android:id="#+id/til_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_title"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:hint="Password"
android:inputType="textPassword"
app:layout_constraintBottom_toTopOf="#+id/tv_forgot_password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/til_phone_number"
app:passwordToggleEnabled="true" />
<TextView
android:id="#+id/tv_forgot_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_password"
android:padding="10dp"
android:paddingStart="30dp"
android:text="Forgot password"
android:textAlignment="textStart"
android:textColor="#color/text_blue"
app:layout_constraintBottom_toTopOf="#+id/btn_login"
app:layout_constraintTop_toBottomOf="#+id/til_password"
tools:layout_editor_absoluteX="24dp" />
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_forgot_password"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:text="Login"
android:translationZ="2dp"
app:layout_constraintBottom_toTopOf="#+id/btn_pin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_forgot_password" />
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btn_pin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/iv_phone"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:text="Use pin"
android:translationZ="2dp"
app:layout_constraintBottom_toTopOf="#+id/view_center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/btn_login" />
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/iv_phone"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:text="Sign up"
android:translationZ="2dp"
app:layout_constraintBottom_toTopOf="#+id/iv_phone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view_center" />
<TextView
android:id="#+id/view_center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/or"
android:textAlignment="center"
android:textColor="#color/filter_black1"
android:translationZ="2dp"
app:layout_constraintBottom_toTopOf="#+id/btn_signup"
app:layout_constraintTop_toBottomOf="#+id/btn_pin" />
<TextView
android:id="#+id/iv_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:src="#drawable/phone_2"
android:text="v1.0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/btn_signup" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Activity layout is:
<merge 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"
tools:context=".login.screens.login.LoginActivity">
<fragment
android:id="#+id/myNavHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:navGraph="#navigation/navigation"
app:defaultNavHost="true"
/>
</merge>
Why blank space appears? How do I get rid of it?
If you not define layout_constraintVertical_chainStyle default is Spread if you want to remove top and bottom space you can define it to app:layout_constraintVertical_chainStyle="spread_inside" more detail you check here

Is there any way to forbid keyboard to move LinearLayout?

I have a fragment and LinearLayout in my activity. In this fragment I have a textview. If there is no ScrollView in fragment, everything works fine. But if there is ScrollView LinearLayout move to the top of keyboard.
This is how my app looks without Scrollview on the text: https://yapx.ru/v/EPcoQ
And this how it looks with it: https://yapx.ru/v/EPcqd
I don't like that Navigation Bar on the bottom isn't hidden when the keyboard is active. What can I do to make app lok like on the first photo andk make textView scrollable?
I've tried to use "windowSoftInputMode" to forbid keyboard move this LinearLayout, but it didn't helped.
I have also tried "focusableInTouchMode" and "isScrollContainer"
attributes, but they were useless too.
This is the activity file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_chetnost"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#86A0FC"
android:windowSoftInputMode="adjustResize"
>
<fragment
android:id="#+id/fragment_theory"
android:name="com.example.user.mathplace_1.theory"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="#+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar" />
<fragment
android:id="#+id/fragment_task"
android:name="com.example.user.mathplace_1.Task"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toTopOf="#+id/linearLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar"
app:layout_constraintVertical_bias="0.0" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="0dp"
android:layout_height="60dp"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="MathPlace"
app:titleTextColor="#fff">
<ImageButton
android:id="#+id/homeButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:layout_marginStart="8dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="6dp"
android:background="#drawable/home"
android:contentDescription="#string/report_description"
android:onClick="delete"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.887"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.987" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="#FFF"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
android:focusableInTouchMode="false"
android:isScrollContainer="false">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#accbff"
android:orientation="horizontal"
android:focusableInTouchMode="false"
android:isScrollContainer="false">
<LinearLayout
android:id="#+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusableInTouchMode="false"
android:isScrollContainer="false"/>
</HorizontalScrollView>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
And this is the fragment code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
xmlns:app="http://schemas.android.com/apk/res-auto">
<EditText
android:id="#+id/editText"
android:layout_width="237dp"
android:layout_height="46dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="Введите ваш ответ"
android:inputType="number"
android:textColor="#5B6175"
android:textSize="23sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#+id/cardView"
app:layout_constraintTop_toBottomOf="#+id/cardView"
app:layout_constraintVertical_bias="0.3" />
<ImageButton
android:id="#+id/send"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:background="#drawable/send"
android:onClick="send"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/cardView"
app:layout_constraintTop_toBottomOf="#+id/cardView"
app:layout_constraintVertical_bias="0.3" />
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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.4">
<ScrollView
android:id="#+id/scrollView4"
android:layout_width="310dp"
android:layout_height="375dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textView3"
android:layout_width="310dp"
android:layout_height="375dp"
android:background="#drawable/text_rounded_corner"
android:padding="8dp"
android:text="dddddddddddddddddddddddd"
android:textColor="#5B6175"
android:textSize="20sp" />
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/textView"
android:layout_width="310dp"
android:layout_height="47dp"
android:background="#drawable/title_rounded_corner"
android:padding="8dp"
android:text="Заголовок"
android:textColor="#FFF"
android:textSize="24sp"
app:layout_constraintBottom_toTopOf="#+id/cardView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="#+id/star2"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="44dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="#+id/textView"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintTop_toTopOf="#+id/textView"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/star" />
<ImageView
android:id="#+id/star1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="#+id/textView"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintTop_toTopOf="#+id/textView"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/star" />
<ImageView
android:id="#+id/star3"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="76dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="#+id/textView"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintTop_toTopOf="#+id/textView"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/star" />
</android.support.constraint.ConstraintLayout>
I've found how I can make my text scrollable without breaking old app view.
I just needed to add one line to the java file:
myTextview.setMovementMethod(new ScrollingMovementMethod());

ConstraintLayout animation using ConstraintSet is not working with ScrollView

I have two layouts with ConstraintLayout which has a child NestedScrollview and NestedScrollview have a child ConstraintLayout again as a container than other views. I want animate both layouts using ConstraintSet but unfortunately, this is not working. On other hands, if I remove NestedScrollview and root ConstraintLayout then it works fine. I want to achieve this task with NestedScrollview or Scroll view is this possible? Thanks in advance.
Here is my Code
activity_login.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:id="#+id/root_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:isScrollContainer="true"
android:orientation="vertical"
tools:context=".activity.LoginActivity">
<!-- Login progress -->
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="8dp">
<!-- Login progress -->
<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/root_lay_la"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="vertical"
tools:context=".activity.LoginActivity">
<ImageView
android:id="#+id/iv_login_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/nature" />
<ProgressBar
android:id="#+id/pb_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tv_login_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:paddingStart="#dimen/fab_margin"
android:paddingTop="#dimen/small_padding"
android:paddingEnd="#dimen/fab_margin"
android:paddingBottom="#dimen/small_padding"
android:text="Login Heading"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="#+id/btn_sign_in_la"
android:layout_width="0dp"
android:layout_height="#dimen/button_size"
android:layout_gravity="center_horizontal"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="32dp"
android:layout_marginEnd="#dimen/fab_margin"
android:layout_marginBottom="8dp"
android:background="#drawable/login_btn_back"
android:paddingStart="#dimen/button_padding"
android:paddingTop="#dimen/normal_padding"
android:paddingEnd="#dimen/button_padding"
android:paddingBottom="#dimen/normal_padding"
android:text="#string/sign_in"
android:textAllCaps="false"
android:textColor="#color/primaryDark"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#+id/iv_login_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/et_password_la"
app:layout_constraintVertical_bias="0.04000002" />
<TextView
android:id="#+id/tv_heading_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:paddingStart="#dimen/big_margin"
android:paddingEnd="#dimen/big_margin"
android:text="Login with Saini Communication and get more offers!"
android:textColor="#color/white"
android:textSize="30sp"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<EditText
android:id="#+id/et_email_or_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="#dimen/big_margin"
android:layout_marginEnd="#dimen/fab_margin"
android:background="#drawable/et_back"
android:drawableStart="#drawable/ic_phone_iphone_black_24dp"
android:drawablePadding="#dimen/fab_margin"
android:ems="10"
android:hint="#string/mobile"
android:inputType="phone"
android:paddingStart="#dimen/normal_padding"
android:paddingTop="#dimen/medium_padding"
android:paddingEnd="#dimen/normal_padding"
android:paddingBottom="#dimen/medium_padding"
android:textColor="#color/white"
android:textColorHint="#color/whiteLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent" />
<EditText
android:id="#+id/et_password_la"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="#dimen/big_margin"
android:layout_marginEnd="#dimen/fab_margin"
android:background="#drawable/et_back"
android:drawableStart="#drawable/ic_lock_black_24dp"
android:drawablePadding="#dimen/fab_margin"
android:ems="10"
android:hint="#string/prompt_password"
android:inputType="textPassword"
android:paddingStart="#dimen/normal_padding"
android:paddingTop="#dimen/medium_padding"
android:paddingEnd="#dimen/normal_padding"
android:paddingBottom="#dimen/medium_padding"
android:textColor="#color/white"
android:textColorHint="#color/whiteLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/et_email_or_phone" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>
activity_login_detial.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:id="#+id/root_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".activity.LoginActivity">
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="8dp">
<!-- Login progress -->
<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/root_lay_la"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="vertical"
tools:context=".activity.LoginActivity">
<ImageView
android:id="#+id/iv_login_back"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
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.26999998"
app:srcCompat="#drawable/nature" />
<ProgressBar
android:id="#+id/pb_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tv_login_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:paddingStart="#dimen/fab_margin"
android:paddingTop="#dimen/small_padding"
android:paddingEnd="#dimen/fab_margin"
android:paddingBottom="#dimen/small_padding"
android:text="Login Heading"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/btn_sign_in_la"
android:layout_width="0dp"
android:layout_height="#dimen/button_size"
android:layout_gravity="center_horizontal"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="32dp"
android:layout_marginEnd="#dimen/fab_margin"
android:layout_marginBottom="8dp"
android:background="#drawable/login_btn_back"
android:paddingStart="#dimen/button_padding"
android:paddingTop="#dimen/normal_padding"
android:paddingEnd="#dimen/button_padding"
android:paddingBottom="#dimen/normal_padding"
android:text="#string/sign_in"
android:textAllCaps="false"
android:textColor="#color/primaryDark"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#+id/iv_login_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/et_password_la"
app:layout_constraintVertical_bias="0.04000002" />
<TextView
android:id="#+id/tv_heading_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:paddingStart="#dimen/big_margin"
android:paddingEnd="#dimen/big_margin"
android:text="Login with Saini Communication and get more offers!"
android:textColor="#color/white"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_login_heading" />
<EditText
android:id="#+id/et_email_or_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="#dimen/big_margin"
android:layout_marginEnd="#dimen/fab_margin"
android:background="#drawable/et_back"
android:drawableStart="#drawable/ic_phone_iphone_black_24dp"
android:drawablePadding="#dimen/fab_margin"
android:ems="10"
android:hint="#string/mobile"
android:inputType="phone"
android:paddingStart="#dimen/normal_padding"
android:paddingTop="#dimen/medium_padding"
android:paddingEnd="#dimen/normal_padding"
android:paddingBottom="#dimen/medium_padding"
android:textColor="#color/white"
android:textColorHint="#color/whiteLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tv_heading_login" />
<EditText
android:id="#+id/et_password_la"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/fab_margin"
android:layout_marginTop="#dimen/big_margin"
android:layout_marginEnd="#dimen/fab_margin"
android:background="#drawable/et_back"
android:drawableStart="#drawable/ic_lock_black_24dp"
android:drawablePadding="#dimen/fab_margin"
android:ems="10"
android:hint="#string/prompt_password"
android:inputType="textPassword"
android:paddingStart="#dimen/normal_padding"
android:paddingTop="#dimen/medium_padding"
android:paddingEnd="#dimen/normal_padding"
android:paddingBottom="#dimen/medium_padding"
android:textColor="#color/white"
android:textColorHint="#color/whiteLight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/et_email_or_phone" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>
LoginActivity.java
#BindView(R.id.root_lay_la)
ConstraintLayout animLay;
public void show(){
show=true;
ConstraintSet constraintSet=new ConstraintSet();
constraintSet.clone(this,R.layout.activity_login_detail);
android.support.transition.Transition transition=new android.support.transition.ChangeBounds();
AnticipateOvershootInterpolator interpolator=new AnticipateOvershootInterpolator(1.5f);
transition.setInterpolator(interpolator);
transition.setDuration(1500);
android.support.transition.TransitionManager.beginDelayedTransition(animLay,transition);
constraintSet.applyTo(animLay);
}
public void hide(){
show =false;
ConstraintSet constraintSet=new ConstraintSet();
constraintSet.clone(this,R.layout.activity_login);
android.support.transition.Transition transition=new android.support.transition.ChangeBounds();
AnticipateOvershootInterpolator interpolator=new AnticipateOvershootInterpolator(1.5f);
transition.setInterpolator(interpolator);
transition.setDuration(1500);
android.support.transition.TransitionManager.beginDelayedTransition(animLay,transition);
constraintSet.applyTo(animLay);
}

Items in Recyclerview adapter jumps to right after i click a button

I have a scrollview as the root layout for my fragment and in that scrollview there is a linearlayout which inside has a constraintlayout and a recyclerview, and there are 2 columns in my recyclerview. When my fragment launches , The UI is fine but when i click on a button a column jumps towards the right side of the screen. im not adding any marginlayout to right or left so I don't know why this is happening. Didn't have this issue before, I am facing this issue after using scrollview. I have pasted the code below. Any ideas as to why the columns change after clicking on a button.
As far as I think, this is an issue with the linear layout because it was fine before I used that.
Fragment 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="scoutingFragmentViewModel"
type="com.resatech.android.navigationtest.viewModels.ScoutingFragmentViewModel">
</variable>
</data>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:fadeScrollbars="false"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusableInTouchMode="true">
<android.support.constraint.ConstraintLayout
android:id="#+id/constraint_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/image_bg"
android:layout_width="385dp"
android:layout_height="285dp"
android:src="#color/cpb_grey"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
<TextView
android:id="#+id/text_scout_timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Scouting Timer"
android:textColor="#color/color_text_dark"
android:textSize="20sp"
android:visibility="#{scoutingFragmentViewModel.mScoutingTimerTextVisibility}"
app:layout_constraintBottom_toBottomOf="#+id/image_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.474"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.335" />
<Button
android:id="#+id/button_ready"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="92dp"
android:layout_marginEnd="30dp"
android:background="#drawable/connect_button"
android:text="Ready"
android:visibility="#{scoutingFragmentViewModel.mReadyButtonVisibility}"
app:layout_constraintEnd_toEndOf="#+id/image_bg"
app:layout_constraintHorizontal_bias="0.484"
app:layout_constraintStart_toStartOf="#+id/image_bg"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button_stop_scouting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/connect_button"
android:text="Stop Scouting"
android:visibility="#{scoutingFragmentViewModel.mStopScoutingButtonVisibility}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.31" />
<Button
android:id="#+id/button_connect"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginStart="8dp"
android:layout_marginTop="88dp"
android:layout_marginEnd="8dp"
android:background="#drawable/connect_button"
android:shadowColor="#A84F4F"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="0"
android:text="Connect"
android:textColor="#140533"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.443"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="500dp"
>
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</ScrollView>
</layout>
Itemlist xml:
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="itemGridViewModel"
type="com.resatech.android.navigationtest.viewModels.ItemGridViewAdapterViewModel" />
</data>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/layout_border"
android:maxWidth="150dp"
android:maxHeight="150dp"
android:layout_marginTop="20dp"
android:paddingVertical="10dp"
app:cardBackgroundColor="#ffffff">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/big_text"
android:layout_width="60dp"
android:layout_height="69dp"
android:layout_marginStart="20dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="21dp"
android:layout_marginBottom="16dp"
android:text="#{itemGridViewModel.values}"
android:textSize="50sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.51"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.526" />
<TextView
android:id="#+id/small_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="21dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="1dp"
android:text="#{itemGridViewModel.description}"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.468"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/big_text" />
<ImageView
android:id="#+id/image"
android:layout_width="23dp"
android:layout_height="22dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="50dp"
app:imageResource="#{itemGridViewModel.imageNames}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.05"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.077" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
</layout>
Display:
try add android:clickable="true" this line into ScrollView
android:clickable="true"
Try to used Recyclerview and set GridLayoutManger and define columns like this way..
recyclerview.setLayoutManager(new GridLayoutManager(this,2,LinearLayoutManager.VERTICAL,false));

Categories

Resources