[kotlin] 가로 스팬
일반적으로 가로 스팬은 그리드나 테이블 레이아웃에서 사용되며, 이를 통해 화면의 여백을 최소화하고 효율적으로 레이아웃을 구성할 수 있습니다.
가로 스팬을 적용하려면 다음과 같이 android:layout_span
속성을 사용하여 해당 요소가 몇 개의 열에 걸쳐 확장될지 지정하면 됩니다.
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3">
<Button
android:text="Button 1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="2" />
<Button
android:text="Button 2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2" />
</GridLayout>
위 예시에서 Button 1
은 2열에 걸쳐 확장되고, Button 2
는 단일 열에만 위치하게 됩니다.
자세한 내용은 안드로이드 공식 문서를 참조하시기 바랍니다. GridLayout - Android Developers