Skip to content

Instantly share code, notes, and snippets.

@linucksrox
Created August 23, 2019 14:25
Show Gist options
  • Save linucksrox/2a5e598ba67558385718a27a2f8ab489 to your computer and use it in GitHub Desktop.
Save linucksrox/2a5e598ba67558385718a27a2f8ab489 to your computer and use it in GitHub Desktop.
lights out button grid layout demo for android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal">
<LinearLayout
android:id="@+id/buttonRowA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_above="@id/buttonRowB">
<Button
android:id="@+id/a0"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/a1"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/a2"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/a3"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/a4"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
</LinearLayout>
<LinearLayout
android:id="@+id/buttonRowB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_above="@id/buttonRowC">
<Button
android:id="@+id/b0"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/b1"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/b2"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/b3"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/b4"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
</LinearLayout>
<LinearLayout
android:id="@+id/buttonRowC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_above="@+id/buttonRowD">
<Button
android:id="@+id/c0"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/c1"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/c2"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/c3"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/c4"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
</LinearLayout>
<LinearLayout
android:id="@+id/buttonRowD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_above="@+id/buttonRowE">
<Button
android:id="@+id/d0"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/d1"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/d2"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/d3"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/d4"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
</LinearLayout>
<LinearLayout
android:id="@+id/buttonRowE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:paddingBottom="10dp">
<Button
android:id="@+id/e0"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/e1"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/e2"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/e3"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
<Button
android:id="@+id/e4"
android:layout_width="@dimen/buttonWidth"
android:layout_height="@dimen/buttonWidth"
android:background="@color/colorLightOff"
android:layout_margin="@dimen/buttonSpacing"/>
</LinearLayout>
</RelativeLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment