LinearLayout 사용해서 위와 똑같이 만들기
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/purple_700"></TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/white"></TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/black"></TextView>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/design_default_color_error"></TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/purple_700"></TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/design_default_color_error"></TextView>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/black"></TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/white"></TextView>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/black"></TextView>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
RelativeLayout 사용해서 위와 똑같이 만들기
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:background="@color/black"></TextView>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:background="@color/black"></TextView>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@color/black">
</TextView>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="@color/black"></TextView>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:background="@color/black"></TextView>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:background="@color/black">
</TextView>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:background="@color/black"></TextView>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:background="@color/black">
</TextView>
<TextView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:background="@color/black"></TextView>
</RelativeLayout>
RelativeLayout 사용해서 위와 똑같이 만들기
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_above="@id/box"
android:layout_centerInParent="true"
android:layout_toLeftOf="@id/box"
android:background="@color/black"></TextView>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@id/box"
android:layout_toLeftOf="@id/box"
android:background="@color/black"></TextView>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_above="@id/box"
android:layout_alignStart="@id/box"
android:background="@color/black"></TextView>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@id/box"
android:layout_alignStart="@id/box"
android:background="@color/black"></TextView>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_toEndOf="@id/box"
android:layout_above="@id/box"
android:background="@color/black"></TextView>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@id/box"
android:layout_toEndOf="@id/box"
android:background="@color/black"></TextView>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_toRightOf="@id/box"
android:layout_alignBottom="@id/box"
android:background="@color/black"></TextView>
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignBottom="@id/box"
android:layout_toLeftOf="@id/box"
android:background="@color/black"></TextView>
<TextView
android:id="@+id/box"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:background="@color/black"></TextView>
</RelativeLayout>