개인공부
안드로이드 : 레이아웃 함수 알아보기
하이후에호
2020. 7. 9. 00:51
반응형
가장 많이쓰는 리니어 레이아웃에 대해 알아 보도록 하겠다.
먼저 소스부터 보자
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="리니어 레이아웃"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="orientation 설정"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Vertical"/>
</LinearLayout>
android:orientation="vertical"
수평으로 설적되어있다.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="리니어 레이아웃"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dddddddd"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dddddddd"/>
</LinearLayout>
android:orientation="horizontal"
수직으로 설적되어있다.
주요속성을 하나식 적용
android:layout_margin 적용시
android:padding="100dp"
gravity와 layout_gravity의 차이
match_parent는 텍스트뷰에 상위 레이아웃 크기에 맞게
wrap_content는 텍스트뷰 글자크기에 맞게
레이아웃안에 레이아웃 구분하기
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ff0000ff">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ffff0000">
</LinearLayout>
</LinearLayout>
페딩은 텍스트뷰안의 공간이고 마진은 텍트트뷰(버튼)밖의 공간
안드로이드 스튜디오 layout 속성 (LinearLayout, RelativeLayout)
이번 포스팅에서는 안드로이드 앱의 기본적인 레이아웃! LinearLayout과 RelativeLayout에 대해 설명드...
blog.naver.com
반응형