Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConstraintLayout: What does `layout_constraintLeft_creator` do in xml?

Example code:

 <EditText         android:id="@+id/msg_type"         android:layout_width="0dp"         android:layout_height="40dp"         android:layout_marginBottom="8dp"         android:layout_marginEnd="8dp"         android:layout_marginStart="8dp"         android:hint="Input message"         app:layout_constraintBottom_toBottomOf="parent"         app:layout_constraintHorizontal_bias="0.75"         app:layout_constraintLeft_toLeftOf="parent"         app:layout_constraintRight_toLeftOf="@+id/btn_chat_send"         tools:layout_constraintBottom_creator="1"         tools:layout_constraintLeft_creator="1"         tools:layout_constraintRight_creator="1"/> 

What does tools:layout_constraintRight_creator="1" do here? There aren't any document explaining these things.

like image 803
guo Avatar asked Nov 17 '16 03:11

guo


People also ask

What does 0dp mean in constraint layout?

for the children of ConstraintLayout if you have set constraints then the 0dp is for match_constraint (take full width, or full height) Using 0dp, which is the equivalent of "MATCH_CONSTRAINT" https://developer.android.com/reference/android/support/constraint/ConstraintLayout.

What is baseline in constraint layout?

It's used to set the top, left, bottom and right constraints of the view. Baseline handle - It's used to align the baseline with another textview in the layout. Let's assign the constraints on the TextView and look into the xml code of it.

What is constraint layout?

A ConstraintLayout is a ViewGroup which allows you to position and size widgets in a flexible way. Note: ConstraintLayout is available as a support library that you can use on Android systems starting with API level 9 (Gingerbread). As such, we are planning on enriching its API and capabilities over time.

What are constraints in Android?

The Layout Editor uses constraints to determine the position of a UI element within the layout. A constraint represents a connection or alignment to another view, the parent layout, or an invisible guideline. You can create the constraints manually, as we show later, or automatically using the Autoconnect tool.


1 Answers

For context -- those are tools attributes -- they are purely here to help the edition in studio. Those attributes actually are stripped out when you push an APK to your device.

Now, the *_creator attributes in ConstraintLayout simply allow us to keep track if you created those constraints manually (0) or via the inference engine (1). If it's the latter and you click again on inference, we know we can safely remove those constraints and recompute new ones.

So basically if you are happy with your layout, you could remove them. But they are already removed when pushed on device.

like image 71
Nicolas Roard Avatar answered Oct 06 '22 04:10

Nicolas Roard