Skip to content

Instantly share code, notes, and snippets.

@joshdholtz
Created June 20, 2012 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshdholtz/2958133 to your computer and use it in GitHub Desktop.
Save joshdholtz/2958133 to your computer and use it in GitHub Desktop.
Android - flex space between views
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout android:id="@+id/activity_webview_toolbar"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="#FF0000">
<Button android:id="@+id/activity_webview_btn_back"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="@drawable/circle_west" />
<!-- This view with weight 1 as a flex space to evenly space out other views -->
<View android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button android:id="@+id/activity_webview_btn_refresh"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="@drawable/refresh" />
<!-- This view with weight 1 as a flex space to evenly space out other views -->
<View android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button android:id="@+id/activity_webview_btn_forward"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="@drawable/circle_east" />
</LinearLayout>
<WebView android:id="@+id/activity_webview_webview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@id/activity_webview_toolbar"/>
</RelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment