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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With