티스토리 뷰

LinearLayout

LinearLayout에서는 horizontally 또는 vertically 로 방향을 나타낸다.

( ConstraintLayout을 통해서 설정하는 방법 : https://constraintlayout.com/layouts/linearlayout.html )

 

LinearLayout을 통해 레이아웃 나누기(비율 2:3)

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="5"
        android:layout_alignParentBottom="true">
    <ImageButton
        android:id="@+id/btnLocEnable"
        android:src="@drawable/ic_location"
        android:layout_width="0dp"
        android:layout_weight="2"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:background="@color/twitter_light_blue"
        />
    <ImageButton
        android:id="@+id/btnUploadPhoto"
        android:src="@drawable/ic_addimage"
        android:layout_width="0dp"
        android:layout_weight="3"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="@color/twitter_light_blue"/>
</LinearLayout>

- LinearLayout 을 android:weightSum = "5" 로 설정

- LinearLayout 안에 속한 ImageButton 을 각각 2, 3으로 설정

- 첫번째 ImageButton 은 2/5 만큼을 차지, 두번째 ImageButton 는 3/5 만큼을 차지한다.


실행화면

추후 추가 예정


공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함