Skip to content

Instantly share code, notes, and snippets.

@RamiJ3mli
Created August 25, 2018 23:28
Show Gist options
  • Save RamiJ3mli/50421bd2b45b497831cc872a6dd37fcb to your computer and use it in GitHub Desktop.
Save RamiJ3mli/50421bd2b45b497831cc872a6dd37fcb to your computer and use it in GitHub Desktop.
Relative percentage based dimensions
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:background="@drawable/bg"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Space
android:id="@+id/anchor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintHorizontal_bias=".7"
app:layout_constraintLeft_toLeftOf="@+id/button"
app:layout_constraintRight_toRightOf="@+id/button" />
<Button
android:id="@+id/another_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/bg_red"
app:layout_constraintLeft_toLeftOf="@+id/button"
app:layout_constraintRight_toRightOf="@+id/anchor"
app:layout_constraintTop_toBottomOf="@+id/button" />
</android.support.constraint.ConstraintLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment