Skip to content

Instantly share code, notes, and snippets.

@extsalt
Created June 22, 2021 11:25
Show Gist options
  • Save extsalt/f5ec6dc8bc87423c2e36671b9c81009c to your computer and use it in GitHub Desktop.
Save extsalt/f5ec6dc8bc87423c2e36671b9c81009c to your computer and use it in GitHub Desktop.
Android Linear Layout Example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="@+id/num1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="10dp"
android:text="Enter number 1"
android:textSize="20dp" />
<EditText
android:id="@+id/num2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="10dp"
android:text="Enter number 2"
android:textSize="20dp" />
<TextView
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:padding="10dp"
android:text="Result: "
android:textSize="20dp" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/purple_200"
android:text="Add"
android:textColor="@color/white"
android:textSize="20dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
android:background="@color/teal_200"
android:padding="10sp"
android:text="Button 2"
android:textColor="@color/white" />
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment