android-constraintlayout

Adding constraints to a view in a ConstraintLayout ignore left and right margins

北战南征 提交于 2019-12-06 02:31:05
I want to add some views to a ConstraintLayout in java. This is the layout xml: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/constraint_layout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.constraint.ConstraintLayout> and this is the code of the activity: public class MainActivity extends AppCompatActivity { private ConstraintLayout

Automatically added ConstraintLayout dependency in gradle

心不动则不痛 提交于 2019-12-06 00:54:32
问题 Just I update my studio (version 2.3) and build version ('25.0.0') , now, when i try to create new activity then automatically constraintlayout dependency added in my build.gradle file. and layout render as parent ConstraintLayout , can anyone know how to remove this dependency when activity is created. Before activity creation gradle code. dependencies { compile 'com.android.support:support-v4:23.2.1' } After activity creation gradle code. dependencies { compile 'com.android.support:support

Add view to constraintLayout with constraints similar to another child

☆樱花仙子☆ 提交于 2019-12-05 13:30:36
I have a constraint layout (alpha9) with views spread all over it, and I have one particular ImageView that I need to replicate and add more of like it. The layout is like so : The main purpose is to animate 5 of those "coin" imageViews when the button is pressed. The imageViews i need to generated sha'll have exact properties of the the imageView behind the Button down below (with same constraints) What i tried to do is the following : private ImageView generateCoin() { ImageView coin = new ImageView(this); constraintLayout.addView(coin,-1,originCoinImage.getLayoutParams());//originCoinImage

What is ConstraintLayout Optimizer?

谁都会走 提交于 2019-12-05 11:52:42
问题 Google published ConstraintLayout 1.1.0 beta 6 on March 22, 2018. It has a new constraint known as Optimizer . The documentation of Optimizer at https://developer.android.com/reference/android/support/constraint/ConstraintLayout.html#Optimizer does not mention when to use and why to use it. Can someone shed some light about it usage. 回答1: Constraint Layout 1.1 adds several new optimizations that speed up your layouts. The optimizations run as a separate pass, and attempt to reduce the number

Constraint layout button text center alignment

为君一笑 提交于 2019-12-05 11:43:22
I'm using the new Constraint layout to build my layout. I need to have Button that occupies almost the entire screen width and that was easy using constraints. As you can see in the image I am setting the width to 0dp (Any size), but the text don't stick at the center what's usually the normal for a button text. I've tried: - set gravity to center - set textAlignment to center Looks like this properties can't work with 0dp width (Any size). So I've tried to set the width to match_parent using gravity center. It's a little bit to the right. Does any one know how to fix that behavior ? Note that

ConstraintLayout doesn't respect max height

倾然丶 夕夏残阳落幕 提交于 2019-12-05 11:05:00
问题 I'm trying to create a layout composition using ConstraintLayout. In order to simplify my case, my layout should have three parts: The first layout (in red), that should grow according to the remaining space and has a max height. The second layout (in green), which has a fixed size of 150dp and should always be below the first layout. The first layout (in pink), also has a fixed size of 150dp and should be aligned to the bottom the view. The part I'm struggling with is setting a max height

How to use ConstraintSet for animation in Android with Java?

泄露秘密 提交于 2019-12-05 10:56:06
I find that there is a quick way to create animation with ConstraintSet for ConstrainLayout Activity. Faster than use TransitionManager for RelativeLayout ConstraintSet use two xml file for an Activity. One for the first position and next one for the destination. I want to create something like this: https://media.giphy.com/media/2UwXdWEoLWe9iQMFIY/giphy.gif But there is no clearly instruction show how to use it in Java. Anyone had done this can show me the source code or link to some post like that. Thanks for reading the post. This is possible with ConstraintSet . They key is two have two

Android ConstraintLayout: How to add a dynamic view one below another

☆樱花仙子☆ 提交于 2019-12-05 10:31:12
I am trying to add TextViews one below another at runtime in a Constraint Layout. But I always end up with just one textview and the rest hiding behind it. I tried several things including chaining the view, but nothing seems to work. private void method(int position) { ConstraintSet set = new ConstraintSet(); TextView textView = new TextView(getContext()); int textViewId = 100 + position; //previousTextViewId = textViewId; textView.setId(textViewId); ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(0, WRAP_CONTENT); layoutParams.rightToRight = PARENT_ID;

ConstraintLayout 1.1.0 different from 1.0.2, is it a bug?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 09:35:17
If I use 1.0.2, the 3 images' width is average, and the height of them is computed by the radio which I set. If I use 1.1.0, the height of them is 0dp and I can't see nothing, unless I set android:layout_height="match_parent" in the root ConstraintLayout . Is it a bug? Here is my code: <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/iv0" android:layout_width="0dp" android:layout_height="0dp" android:background="#FF0000" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight

Is it advisable to use LinearLayout inside ConstraintLayout in Android?

不问归期 提交于 2019-12-05 09:26:40
问题 I am new to ConstraintLayout in Android and newbie to Android too. I have a question. Is it advisable to use LinearLayout inside ConstraintLayout ? For example: <?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" app:srcCompat="@drawable/landing_screen" android:layout