Skip to content

Instantly share code, notes, and snippets.

@karthiks
Created April 17, 2016 08:03
Show Gist options
  • Save karthiks/c1ee47c8ccd7436a87c5bbaeebff7b28 to your computer and use it in GitHub Desktop.
Save karthiks/c1ee47c8ccd7436a87c5bbaeebff7b28 to your computer and use it in GitHub Desktop.
Lesson Learnt playing with RelativeLayout in Android UI
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</ScrollView>
<LinearLayout
android:id="@+id/buttonsRowLayout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@+id/scrollView"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/readTextButton"
android:text="@string/read_text"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="readTextFile"/>
<Button
android:id="@+id/readJSONButton"
android:text="@string/read_json"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="readJSONFile"/>
<Button
android:id="@+id/readXMLButton"
android:text="@string/read_xml"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="readXMLFile"/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/buttonsRowLayout"
android:layout_margin="5dp">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</ScrollView>
<LinearLayout
android:id="@+id/buttonsRowLayout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/readTextButton"
android:text="@string/read_text"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="readTextFile"/>
<Button
android:id="@+id/readJSONButton"
android:text="@string/read_json"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="readJSONFile"/>
<Button
android:id="@+id/readXMLButton"
android:text="@string/read_xml"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:onClick="readXMLFile"/>
</LinearLayout>
</RelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment