Created
August 24, 2017 13:58
-
-
Save PierceZ/17c7133b1215c6cc42d1eca1c2cf714a to your computer and use it in GitHub Desktop.
A ConstraintLayout that uses a percentage width.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <android.support.constraint.ConstraintLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content"> | |
| <android.support.constraint.Guideline | |
| android:id="@+id/guideline1" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:orientation="vertical" | |
| app:layout_constraintGuide_percent="0.25"/> | |
| <TextView | |
| android:id="@+id/textView1" | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:background="@android:color/holo_blue_bright" | |
| android:text="1" | |
| android:textSize="44sp" | |
| app:layout_constraintLeft_toLeftOf="parent" | |
| app:layout_constraintRight_toLeftOf="@id/guideline1"/> | |
| <TextView | |
| android:id="@+id/textView2" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:background="@android:color/holo_blue_dark" | |
| android:text="2" | |
| android:textSize="44sp" | |
| app:layout_constraintLeft_toRightOf="@+id/textView1"/> | |
| <TextView | |
| android:id="@+id/textView3" | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:background="@android:color/holo_green_dark" | |
| android:text="3" | |
| android:textSize="44sp" | |
| app:layout_constraintLeft_toRightOf="@+id/textView2" | |
| app:layout_constraintRight_toRightOf="parent"/> | |
| <TextView | |
| android:id="@+id/textView4" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:background="@android:color/holo_orange_dark" | |
| android:text="4" | |
| android:textSize="44sp" | |
| app:layout_constraintLeft_toRightOf="@+id/textView1" | |
| app:layout_constraintTop_toBottomOf="@+id/textView1"/> | |
| </android.support.constraint.ConstraintLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of version 1.1, you can use
app:layout_constraintWidth_percent.