Android Studio

GridLayout

GOD03219 2018. 2. 5. 11:40

<?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"
tools:context="com.example.i310_54.myapplication08.MainActivity"
>

<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

 

 


android:columnCount="3"
android:rowCount="2"
>

<Button android:text="1" />
<Button android:text="1" />
<Button android:text="1" />
<Button android:text="1" />
<Button android:text="1" />
<Button android:text="1" />

</GridLayout>


</LinearLayout>

<?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"
tools:context="com.example.i310_54.myapplication08.MainActivity"

>

<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3"
android:rowCount="2"
>

<Button android:text="1" android:layout_row="0" android:layout_column="0"/>
<Button android:text="1" android:layout_row="0" android:layout_column="1"/>
<Button android:text="1" android:layout_row="0" android:layout_column="2"/>
<Button android:text="1" android:layout_row="1" android:layout_column="0"/>
<Button android:text="1" android:layout_row="1" android:layout_column="1"/>
<Button android:text="1" android:layout_row="1" android:layout_column="2"/>

</GridLayout>


</LinearLayout>

 * android:layout_row 와 column은 필수 속성은 아니지만 그 부분(ex.0,1)만 지우고 싶을때 주석 잡고 쓰임