티스토리 뷰

In LinearLayout


1. weight와 weightSum

<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:weightSum="1"

android:background="#ffffffff">

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="0.7"

android:background="#ff000000"/>

</LinearLayout>


1) 비율을 정확히 고정시키고 싶을 때는


자체 테이블을 그리거나 할 때 TableLayout을 사용하면 알아서 늘어나고 줄어드는 컬럼 때문에 정신건강에 좋지 않다. 이럴 때는 LinearLayout을 이용해서 android:layout_width를 0px로 변경하고, weight로 비율을 고정하면 늘어나고 줄어들지 않게 고정시킬 수 있다. 정확히 나뉜 컬럼이 필요하거나 할 때는 이 방법을 이용한다. 단, 이렇게 나뉘는 영역에는 당연하겠지만 margin이 포함되지 않으니 margin을 함부로 사용하면 어그러진다. padding을 잘 활용해야 한다.


android:layout_width="0px"

android:layout_height="wrap_content"

android:layout_weight="0.25"



댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday