Skip to content

Instantly share code, notes, and snippets.

@chrishuan9
Created July 28, 2012 10:14
Show Gist options
  • Save chrishuan9/3192782 to your computer and use it in GitHub Desktop.
Save chrishuan9/3192782 to your computer and use it in GitHub Desktop.
50/50 Layout Split with RelativeLayout in Android by using an invisible View and centering it
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<View android:id="@+id/strut"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerHorizontal="true"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignRight="@id/strut"
android:layout_alignParentLeft="true"
android:text="Left"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/strut"
android:layout_alignParentRight="true"
android:text="Right"/>
</RelativeLayout>
@rizwan-sohaib-kinnect2
Copy link

awesome solution.. thank you man.

@carlosgasa
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment