I'm using Android Oreo AutoTextSize capability in my project.
Every thing works fine except that at first when RecyclerView being loaded, some of textView that uses AutoTextSize has a margin bottom on some RecyclerView items but when I scroll down and then come back to that items, problem solves.
and Although in some items, length of TextView is same with another item, but text sizes are different.
You can see my problem in below image :
When I scroll down and then come back, it is ok
here is items layout :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="#android:color/white"
app:cardCornerRadius="10dp"
app:cardElevation="3dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:id="#+id/fessMetaCL"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginEnd="2dp"
android:layout_marginStart="2dp"
android:layout_marginTop="24dp"
android:background="#drawable/fees_item_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/fee_currency_icon"
app:layout_constraintVertical_bias="1.0">
<android.support.v7.widget.AppCompatTextView
android:id="#+id/fees_update_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="#string/lastupdate"
android:textColor="#color/fees_text_color"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/fee_currency_date"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="#+id/fee_currency_stock"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/fee_currency_date"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:maxLines="1"
android:textColor="#color/fees_text_color"
app:autoSizeMaxTextSize="#dimen/order_result_text_max_size"
app:autoSizeMinTextSize="#dimen/order_result_text_min_size"
app:autoSizeStepGranularity="#dimen/order_result_text_rise_step_size"
app:autoSizeTextType="uniform"
app:layout_constraintBaseline_toBaselineOf="#+id/fees_update_label"
app:layout_constraintEnd_toEndOf="parent" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/fees_stock_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="#string/stock"
android:textColor="#color/fees_text_color"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/fee_currency_stock"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:maxLines="1"
android:textColor="#color/fees_text_color"
app:autoSizeMaxTextSize="#dimen/order_result_text_max_size"
app:autoSizeMinTextSize="#dimen/order_result_text_min_size"
app:autoSizeStepGranularity="#dimen/order_result_text_rise_step_size"
app:autoSizeTextType="uniform"
app:layout_constraintBaseline_toBaselineOf="#+id/fees_stock_label"
app:layout_constraintStart_toEndOf="#+id/fees_stock_label" />
</android.support.constraint.ConstraintLayout>
<ImageView
android:id="#+id/fee_currency_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/others" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/fee_currency_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:textColor="#color/fees_text_color"
android:textSize="#dimen/dashboard_fees_small_font_size"
app:layout_constraintStart_toEndOf="#+id/fee_currency_icon"
app:layout_constraintTop_toTopOf="#+id/fee_currency_icon" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/fee_currency_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/fees_text_color"
android:textSize="#dimen/dashboard_fees_small_font_size"
app:layout_constraintBottom_toBottomOf="#+id/fee_currency_icon"
app:layout_constraintStart_toStartOf="#+id/fee_currency_name"
app:layout_constraintTop_toBottomOf="#+id/fee_currency_name" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/fee_currency_change"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:textColor="#color/fees_text_color"
android:textSize="#dimen/dashboard_fees_big_font_size"
app:layout_constraintBottom_toBottomOf="#+id/fee_currency_icon"
app:layout_constraintStart_toStartOf="#+id/guideline4"
app:layout_constraintTop_toTopOf="#+id/fee_currency_icon" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/fees_change_tip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="#string/change"
android:textColor="#color/fees_text_color"
android:textSize="#dimen/dashboard_fees_small_font_size"
app:layout_constraintBottom_toBottomOf="#+id/fee_currency_change"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#+id/fee_currency_change" />
<android.support.constraint.Guideline
android:id="#+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="187dp" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
Related
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>
I'm using constraintlayout and I have an activity that is a user profile. and it includes a picture of user. when I code xml layout. I can see the picture in preview window inside android studio the image is a png image. I have tried changing the image to one of the android studio avatar. still doesn't work. however, when I run the app the picture is not displaying. does anyone know why this happen?
<?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:background="#color/profileBackground">
<android.support.constraint.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginBottom="8dp"
android:background="#drawable/bacround_gradient"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.001">
<TextView
android:id="#+id/name_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="72dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif-condensed-medium"
android:text="Amanda Bozquet"
android:textAlignment="center"
android:textColor="#color/headerTextColor"
android:textSize="25sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<ImageView
android:id="#+id/user_imageview"
android:layout_width="126dp"
android:layout_height="109dp"
android:layout_marginStart="8dp"
android:layout_marginTop="144dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="#drawable/prifile_pic" />
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:paddingBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/user_imageview"
app:layout_constraintVertical_bias="0.275">
<TextView
android:id="#+id/occupation_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="Marine Biologist"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/workplace_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="Key Biscaine National Park"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/occupation_textview" />
<TextView
android:id="#+id/state_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="FL, USA"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/workplace_textview" />
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/state_textview">
<ImageView
android:id="#+id/email_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.126"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/state_textview"
app:srcCompat="#drawable/ic_mail_black_24dp" />
<TextView
android:id="#+id/email_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="8dp"
android:text="abozquet#biscainepark.org"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.031"
app:layout_constraintStart_toEndOf="#+id/email_imageview"
app:layout_constraintTop_toBottomOf="#+id/state_textview" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout">
<ImageView
android:id="#+id/phone_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.126"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/email_imageview"
app:srcCompat="#drawable/ic_local_phone_black_24dp" />
<TextView
android:id="#+id/phone_textview"
android:layout_width="239dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="184dp"
android:text="1 (786) 352-2254"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.031"
app:layout_constraintStart_toEndOf="#+id/phone_imageview"
app:layout_constraintTop_toBottomOf="#+id/email_textview" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout2">
<ImageView
android:id="#+id/video_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.126"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/phone_imageview"
app:srcCompat="#drawable/ic_videocam_white_24dp" />
<TextView
android:id="#+id/video_textview"
android:layout_width="242dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="184dp"
android:text="1 (786) 352-2254"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.031"
app:layout_constraintStart_toEndOf="#+id/video_imageview"
app:layout_constraintTop_toBottomOf="#+id/phone_textview" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout3">
<ImageView
android:id="#+id/facebook_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.126"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/video_textview"
app:srcCompat="#drawable/ic_icon_facebook" />
<TextView
android:id="#+id/facebook_textview"
android:layout_width="336dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="184dp"
android:text="http://facebook.com/amandab"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.031"
app:layout_constraintStart_toEndOf="#+id/facebook_imageview"
app:layout_constraintTop_toBottomOf="#+id/video_textview" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout4">
<ImageView
android:id="#+id/twitter_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.126"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/facebook_textview"
app:srcCompat="#drawable/ic_twitter_white" />
<TextView
android:id="#+id/twitter_textview"
android:layout_width="336dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="184dp"
android:text="\#mandabuz48"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.031"
app:layout_constraintStart_toEndOf="#+id/twitter_imageview"
app:layout_constraintTop_toBottomOf="#+id/facebook_textview" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
From: https://developer.android.com/studio/write/tool-attributes
Android Studio supports a variety of XML attributes in the tools
namespace that enable design-time features (such as which layout to
show in a fragment) or compile-time behaviors (such as which shrinking
mode to apply to your XML resources). When you build your app, the
build tools remove these attributes so there is no effect on your APK
size or runtime behavior.
So the attribute:
tools:src="#drawable/prifile_pic"
is valid only for design-time.
It is not compiled in the APK and you will not see the image when you run the app.
Change it to:
app:srcCompat="#drawable/prifile_pic"
Do any of your ImageViews display the intended images? Your profile pic ImageView is using tools:src while others are using app:srcCompat
I just noticed a potential typo too -
tools:src="#drawable/prifile_pic" <<--- supposed to be profile_pic?
Are you getting any exception in your android studio log-cat, like image not found? As Stitches wrote in above comment --> typo error for prifile_pic, please check you drawable name is same in your xml layout and image name in drawable folder.
I have built a layout using ConstraintLayout for my android application. The application will be only available on mobile (no TV or Tablets). But honestly I don't how to make the layout perfectly fit the phone size.
Here's one of my activity
<?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:background="#color/colorPrimary"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:fontFamily="#font/billabong"
android:gravity="center"
android:text="Applikáció"
android:textColor="#color/white"
android:textSize="65sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.054" />
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayoutEmail"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textColorHint="#color/inputText"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.505"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView"
app:layout_constraintVertical_bias="0.255">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/inputText"
android:hint="E-mail cim"
android:inputType="text"
android:textColor="#color/colorAccent"
android:textColorHint="#color/colorPrimaryLight"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="214dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayoutPassword"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textColorHint="#color/inputText"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/inputLayoutEmail"
app:layout_constraintVertical_bias="0.0">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/inputText"
android:textColor="#color/colorAccent"
android:hint="Jelszó"
android:inputType="textPassword"
android:textColorHint="#color/colorPrimaryLight" />
</android.support.design.widget.TextInputLayout>
<CheckBox
android:id="#+id/checkBox"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="21dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:buttonTint="#color/colorAccent"
android:hint="Maradjak bejelentkezve"
android:textColorHint="#color/inputText"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/inputLayoutPassword"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="#+id/login_button"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="28dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/button_style_1"
android:onClick="onClickButtonMain"
android:text="Bejelentkezés"
android:textColor="#color/white"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/checkBox"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="#+id/registration_button"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="18dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/button_style_blue"
android:onClick="onClickButtonMain"
android:text="Regisztráció"
android:textColor="#color/white"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.494"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_button"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="#+id/information_button"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/button_style_2"
android:onClick="onClickButtonMain"
android:text="Lépések"
android:textColor="#color/colorAccent"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.505"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/registration_button"
app:layout_constraintVertical_bias="0.612" />
</android.support.constraint.ConstraintLayout>
This layout looks great on Pixel but for example on Nexus S the buttons and margins like they don't actually care about how I defined them. I really would like to know what am I doing wrong. I would like to be able to build responsive layouts.
In Android, you need to consider the number of different screen sizes when developing an android application.
Different phones got different screen size, in your layout you are using fixed size on your view (fixed size is android:layout_width="300dp" for example) and the result is that what may look good on one screen (your android studio preview screen)but will not look good on another screen (your actual phone).
For your case, I recommend using Chains and Guildelines, this will make your layout responsive.
Here is an example of the layout that you want to achieve using ConstraintLayout:
<?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">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="Applikáció"
android:textSize="65sp"
app:layout_constraintBottom_toTopOf="#+id/guideline6"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp" />
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayoutEmail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColorHint="#color/inputText"
app:layout_constraintBottom_toTopOf="#+id/inputLayoutPassword"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/guideline8"
app:layout_constraintTop_toTopOf="#+id/guideline6">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/inputText"
android:hint="E-mail cim"
android:inputType="text"
android:textColor="#color/colorAccent"
android:textColorHint="#color/colorPrimaryLight" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayoutPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColorHint="#color/inputText"
app:layout_constraintBottom_toTopOf="#+id/checkBox"
app:layout_constraintEnd_toEndOf="#+id/inputLayoutEmail"
app:layout_constraintStart_toStartOf="#+id/inputLayoutEmail"
app:layout_constraintTop_toBottomOf="#+id/inputLayoutEmail">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/inputText"
android:hint="Jelszó"
android:inputType="textPassword"
android:textColor="#color/colorAccent"
android:textColorHint="#color/colorPrimaryLight" />
</android.support.design.widget.TextInputLayout>
<CheckBox
android:id="#+id/checkBox"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:buttonTint="#color/colorAccent"
android:hint="Maradjak bejelentkezve"
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="#+id/login_button"
app:layout_constraintEnd_toEndOf="#+id/inputLayoutEmail"
app:layout_constraintStart_toStartOf="#+id/inputLayoutEmail"
app:layout_constraintTop_toBottomOf="#+id/inputLayoutPassword" />
<Button
android:id="#+id/login_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="onClickButtonMain"
android:text="Bejelentkezés"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/registration_button"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/inputLayoutEmail"
app:layout_constraintTop_toBottomOf="#+id/checkBox" />
<Button
android:id="#+id/registration_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="onClickButtonMain"
android:text="Regisztráció"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/information_button"
app:layout_constraintEnd_toStartOf="#+id/guideline7"
app:layout_constraintStart_toStartOf="#+id/inputLayoutEmail"
app:layout_constraintTop_toBottomOf="#+id/login_button" />
<Button
android:id="#+id/information_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="onClickButtonMain"
android:text="Lépések"
android:textColor="#color/colorAccent"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/inputLayoutEmail"
app:layout_constraintStart_toStartOf="#+id/inputLayoutEmail"
app:layout_constraintTop_toBottomOf="#+id/registration_button" />
<android.support.constraint.Guideline
android:id="#+id/guideline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="20dp"
app:layout_constraintGuide_percent="0.25" />
<android.support.constraint.Guideline
android:id="#+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent=".9" />
<android.support.constraint.Guideline
android:id="#+id/guideline8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent=".1" />
</android.support.constraint.ConstraintLayout>
It will look like this (I am adding a picture from the layout editor so you can see the guidelines):
Now all that left to do is to style your views and you have your layout ready.
I have an app that displays long strings of text with the press of some buttons, the problem comes when I display a lot of text and the ScrollView just stops scrolling for some reason.
Here is the xml of my app:
<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"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="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/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="14dp"
android:layout_marginStart="16dp"
android:layout_marginTop="128dp"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="#+id/atbutt"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.089" />
</ScrollView>
<Button
android:id="#+id/namebutt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:onClick="changename"
android:text="Name"
app:layout_constraintEnd_toStartOf="#+id/titlebutt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/titlebutt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:onClick="changetitle"
android:text="Title"
app:layout_constraintEnd_toStartOf="#+id/descbutt"
app:layout_constraintStart_toEndOf="#+id/namebutt"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/descbutt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:onClick="changedesc"
android:text="Description"
android:textSize="13dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/titlebutt"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/urlbutt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="11dp"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:onClick="changeurl"
android:text="Url"
app:layout_constraintEnd_toStartOf="#+id/atbutt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/namebutt" />
<Button
android:id="#+id/atbutt"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginEnd="14dp"
android:layout_marginTop="20dp"
android:onClick="changeat"
android:text="Publish Date"
android:textSize="12dp"
app:layout_constraintEnd_toStartOf="#+id/contbutt"
app:layout_constraintStart_toEndOf="#+id/urlbutt"
app:layout_constraintTop_toBottomOf="#+id/titlebutt" />
<Button
android:id="#+id/contbutt"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="17dp"
android:onClick="changecont"
android:text="Content"
app:layout_constraintBottom_toBottomOf="#+id/atbutt"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/atbutt"
app:layout_constraintTop_toTopOf="#+id/atbutt"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>
I have seen some people use this same method that I'm using here and it works for them just fine.
Your layout has a few things that look wrong and could explain
undefined behaviour.
change the ScrollView height and width to 0dp which means to respect the constraints set on the view
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
...
Remove the constraints from the child of the ScrollView as ContraintLayout only applies rules to direct children.
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="14dp"
android:layout_marginStart="16dp"
android:layout_marginTop="128dp"
android:text=""
/>
My xml is composed by one constraint layout. Inside this there are 2 buttons and 1 nested scroll view. Inside the ScrollView there are various elements including recycle view. I would like that the recycle view not scroll but scroll only the nested scroll view. I have disabled the scroll of recycle view in this mode
(recyclerView.setNestedScrollingEnabled(false);)
but the problem is that the nested scroll view not scrolling. Can you help me?
I attach the code below.
The code start in this mode :
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="#+id/azzera"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginStart="40dp"
android:layout_marginBottom="28dp"
android:background="#drawable/rounded_4lati"
android:backgroundTint="#color/azzurro"
android:elevation="#dimen/dimen8"
android:paddingTop="#dimen/dimen8"
android:text="#string/azzera"
android:textAlignment="center"
android:textColor="#FFFFFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/conferma"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="28dp"
android:background="#drawable/rounded_4lati"
android:backgroundTint="#color/azzurro"
android:paddingTop="#dimen/dimen8"
android:text="#string/conferma"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:elevation="#dimen/dimen8"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<android.support.v4.widget.NestedScrollView 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"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="#+id/view1"
android:layout_width="0dp"
android:layout_height="48dp"
android:background="#color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="#+id/view2"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:background="#color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/view1" />
<View
android:id="#+id/view3"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:background="#color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/view2" />
<TextView
android:id="#+id/mostraPreferiti"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="#string/mostraPreferiti"
android:textColor="#color/black"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/view3" />
<TextView
android:id="#+id/creditiEcm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:text="#string/creditiECM"
android:textColor="#color/black"
android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/view1" />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:inputType="number"
android:hint="#string/zero"
android:text="#string/editText"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="#+id/creditiEcm"
app:layout_constraintTop_toTopOf="#+id/view1"
android:autofillHints="" />
<Button
android:id="#+id/buttonMeno"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="16dp"
android:background="#drawable/ic_remove_circle_azzurro_24dp"
android:gravity="center"
android:textAlignment="gravity"
android:textColor="#color/azzurro"
android:textSize="24sp"
app:layout_constraintEnd_toStartOf="#+id/buttonPiu"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/buttonPiu"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="32dp"
android:background="#drawable/ic_add_circle_azzurro_24dp"
android:gravity="center"
android:textAlignment="gravity"
android:textColor="#color/azzurro"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/mostraCorsiPassati"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="#string/mostraCorsiPassati"
android:textColor="#color/black"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/view2"
app:layout_constraintTop_toTopOf="#+id/view2" />
<Switch
android:id="#+id/switch_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:theme="#style/SwitchTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/view2" />
<Switch
android:id="#+id/switch_button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:theme="#style/SwitchTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/view3" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/professioni"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="90dp"
android:layout_marginEnd="8dp"
android:text="#string/professione2"
android:textColor="#color/black"
android:textSize="18sp"
android:textStyle="bold"
app:fontFamily="#font/sanfrancisco"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mostraCorsiPassati" />
<SearchView
android:id="#+id/searchBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:background="#fff"
android:elevation="2dp"
app:layout_constraintHorizontal_bias="0.557"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintRight_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/professioni"
app:queryHint="Cerca..">
</SearchView>
<android.support.v7.widget.RecyclerView
android:id="#+id/listProfessioni"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/searchBar"
android:orientation="vertical"
>
</android.support.v7.widget.RecyclerView>
<TextView
android:id="#+id/professioniNonDisponibili"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:text="#string/professioniNonDisponibili"
android:textAlignment="center"
android:textColor="#color/gray"
android:textSize="18sp"
app:autoSizeMaxTextSize="#dimen/dimen20"
app:autoSizeMinTextSize="#dimen/dimen12"
app:autoSizeTextType="uniform"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/error" />
<ImageView
android:id="#+id/error"
android:layout_width="#dimen/dimen80"
android:layout_height="#dimen/dimen80"
android:layout_marginStart="8dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/ic_error_outline_gray_24dp"
android:contentDescription="#string/TODO"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/searchBar"
app:layout_constraintVertical_bias="0.105" />
<ProgressBar
android:id="#+id/progress"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:alpha="1"
android:minWidth="80dp"
android:minHeight="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/searchBar"
app:layout_constraintVertical_bias="0.168" />
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
As i answered in comments
For Someone other facing same problem. This might help.
For some reasons ScrollView doesn't scroll when having ConstraintLayout inside it.
For Workaround we can use LinearLayout or RelativeLayoutinstead of ConstraintLayout inside ScrollView. OR
As OP does put the ConstraintLayout inside Linear or Relative Layout does the trick.
According to Ali Ahmed's answer, a ScrollView doesn't scroll if you have a ConstraintLayout inside it. Well that's not true. I have been using ConstraintLayout inside ScrollView and everything works perfectly fine. Well the problem with the code that you posted is that you are using 0dpas the layout_height of your RecyclerView. 0dp means match_parent. You should be using wrap_content as your layout_height. So that the RecyclerView expands its height according to the elements in it. Doing so will make your code work fine.