Skip to content

Instantly share code, notes, and snippets.

@PierceZ
Created August 24, 2017 13:20
Show Gist options
  • Save PierceZ/66f3931378e51ceb8ed05887f9a661d4 to your computer and use it in GitHub Desktop.
Save PierceZ/66f3931378e51ceb8ed05887f9a661d4 to your computer and use it in GitHub Desktop.
An example to compare RelativeLayout to ConstraintLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="@android:color/holo_blue_bright"
android:text="1"
android:textSize="44sp"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/textView1"
android:background="@android:color/holo_blue_dark"
android:text="2"
android:textSize="44sp"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/textView2"
android:background="@android:color/holo_green_dark"
android:text="3"
android:textSize="44sp"/>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_toRightOf="@+id/textView1"
android:background="@android:color/holo_orange_dark"
android:text="4"
android:textSize="44sp"/>
</RelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment