안드로이드 앱 만들기
Table Layout
khon98
2020. 9. 15. 22:12
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="100dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="100dp"
android:stretchColumns="*"
android:background="@drawable/table_outside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside_gray"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:layout_span="2"
android:text="khon"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/table_inside"
android:gravity="center"
android:text="khon"
android:textSize="18sp" />
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
--------------------------------
xml파일 생성
--------------------------------
table_outside.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="3dp"
android:color="#000000"/>
</shape>
xml 파일 복사
--------------------------------
xml 파일 붙여넣기 후 이름 변경
--------------------------------
table_inside.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<stroke android:width="1dp"
android:color="#000000"/>
</shape>
xml 파일 복사
--------------------------------
xml 파일 붙여넣기 후 이름 변경
--------------------------------
table_inside_gray.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#8A8A8A"/>
<stroke android:width="1dp"
android:color="#000000"/>
</shape>
--------------------------------