개발/안드로이드(Android-Kotlin)

레이아웃 절반 등분하기

개복치 개발자 2019. 6. 25. 01:45

안드로이드에서 레이아웃을 딱 맞춰서 절반 나누는 방법입니다.

<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:weightSum="2">

  <LinearLayout
  android:layout_weight="1"
  android:layout_height="wrap_content"
  android:layout_width="0dp">


  </LinearLayout>

  <LinearLayout
  android:layout_weight="1"
  android:layout_height="wrap_content"
  android:layout_margin="5dp"
  android:layout_width="0dp">

  </LinearLayout>

</LinearLayout>

맨 위에 감싸는 LinearLayout 에 weightSum=""에 N등분 할지를 정해서

안에 들어가는 LinearLayout에 layout_weight="1"로 하면 1/N로 됩니다.

매우 간단합니다.

 

'개발 > 안드로이드(Android-Kotlin)' 카테고리의 다른 글

Retrofit, JSON, GSON, OkHttp, API 란  (0) 2019.07.31
전화하기 버튼  (0) 2019.07.25
Andorid Audio 파일 재생  (0) 2019.07.25
Android background radius  (0) 2019.06.25
Android thread  (0) 2019.06.21