Is it possible to put a ConstraintLayout inside a ScrollView?
Try adding android:fillViewport=”true” to the ScrollView. Found the solution here: LinearLayout not expanding inside a ScrollView
Try adding android:fillViewport=”true” to the ScrollView. Found the solution here: LinearLayout not expanding inside a ScrollView
Update ConstraintLayout now supports negative margins with version 2.1.0-alpha2. Simply state android:layout_marginTop=”-25dp” for a negative 25dp margin. (This will only work if the top of the view is constrained. A margin has no effect in ConstraintLayout if the margin’s side is not constrained.) Clarification: The answer below remains valid, but I want to clarify a … Read more
Updated (ConstraintLayout 1.1.+) Use app:layout_constrainedWidth=”true” with android:layout_width=”wrap_content” Previously (deprecated): app:layout_constraintWidth_default=”wrap” with android:layout_width=”0dp”
It seems that it is working, I don’t know what dependency you were working with but in this one compile ‘com.android.support.constraint:constraint-layout:1.0.2’ Is working, this is what I did <?xml version=”1.0″ encoding=”utf-8″?> <ScrollView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” tools:context=”.MainActivity”> <android.support.constraint.ConstraintLayout android:layout_width=”match_parent” android:layout_height=”wrap_content”> <android.support.design.widget.TextInputLayout android:id=”@+id/til_input” android:layout_width=”0dp” android:layout_height=”wrap_content” android:hint=”Escriba el contenido del archivo” app:layout_constraintLeft_toLeftOf=”parent” app:layout_constraintRight_toLeftOf=”@+id/btn_save” app:layout_constraintTop_toTopOf=”@id/btn_save” app:layout_constraintVertical_chainStyle=”spread”> <EditText … Read more
To set constraints of image view to: app:layout_constraintRight_toRightOf=”@+id/check_answer1″ app:layout_constraintTop_toTopOf=”@+id/check_answer1″ use: ConstraintLayout constraintLayout = findViewById(R.id.parent_layout); ConstraintSet constraintSet = new ConstraintSet(); constraintSet.clone(constraintLayout); constraintSet.connect(R.id.imageView,ConstraintSet.RIGHT,R.id.check_answer1,ConstraintSet.RIGHT,0); constraintSet.connect(R.id.imageView,ConstraintSet.TOP,R.id.check_answer1,ConstraintSet.TOP,0); constraintSet.applyTo(constraintLayout); To set constraints of image view to: app:layout_constraintRight_toRightOf=”@+id/check_answer2″ app:layout_constraintTop_toTopOf=”@+id/check_answer2″ use: ConstraintLayout constraintLayout = findViewById(R.id.parent_layout); ConstraintSet constraintSet = new ConstraintSet(); constraintSet.clone(constraintLayout); constraintSet.connect(R.id.imageView,ConstraintSet.RIGHT,R.id.check_answer2,ConstraintSet.RIGHT,0); constraintSet.connect(R.id.imageView,ConstraintSet.TOP,R.id.check_answer2,ConstraintSet.TOP,0); constraintSet.applyTo(constraintLayout);
There are two ways to accomplish this using ConstraintLayout: Chains and Guidelines. To use Chains, make sure you are using ConstraintLayout Beta 3 or newer and if you want to use the visual layout editor in Android Studio, make sure you are using Android Studio 2.3 Beta 1 or newer. Method 1 – Using Chains … Read more
The intention of ConstraintLayout is to optimize and flatten the view hierarchy of your layouts by applying some rules to each view to avoid nesting. The Rules are similar to RelativeLayout, for example setting the bottom edge to the bottom of some other view. app:layout_constraintBottom_toBottomOf=”@+id/view1″ Unlike RelativeLayout, ConstraintLayout offers a bias value that is used … Read more
There is a simpler way. If you set layout constraints as follows and your EditText is fixed sized, it will get centered in the ConstraintLayout: app:layout_constraintLeft_toLeftOf=”parent” app:layout_constraintRight_toRightOf=”parent” app:layout_constraintTop_toTopOf=”parent” app:layout_constraintBottom_toBottomOf=”parent” The left/right pair centers the view horizontally and top/bottom pair centers it vertically. This is because when you set the left, right or top,bottom constraints bigger … Read more
It may be useful to have a quick reference here. Placement of views Use a guideline with app:layout_constraintGuide_percent like this: <androidx.constraintlayout.widget.Guideline android:id=”@+id/guideline” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:orientation=”vertical” app:layout_constraintGuide_percent=”0.5″/> And then you can use this guideline as anchor points for other views. or Use bias with app:layout_constraintHorizontal_bias and/or app:layout_constraintVertical_bias to modify view location when the available space allows … Read more