Jetpack Compose는 Android에 권장되는 UI 도구 키트입니다. Compose에서 레이아웃을 사용하는 방법을 알아보세요.
<ph type="x-smartling-placeholder"></ph>
열 또는 행 →
를 통해 개인정보처리방침을 정의할 수 있습니다.
LinearLayout
모든 하위 요소를 한 방향, 즉 세로 또는 가로로 정렬하는 뷰 그룹입니다.
가로 방향으로 돌립니다. 다음과 같이 레이아웃 방향을 지정할 수 있습니다.
android:orientation 드림
속성의 값을 제공합니다.
<ph type="x-smartling-placeholder">를 통해 개인정보처리방침을 정의할 수 있습니다.
<ph type="x-smartling-placeholder"></ph>
<ph type="x-smartling-placeholder"></ph>
<ph type="x-smartling-placeholder"></ph>
그림 1. 가로 3개가 있는 LinearLayout
고취하는 아이들이었기 때문입니다.
LinearLayout의 모든 하위 요소는 차례로 스택됩니다.
따라서 세로 목록에는 너비에 관계없이 행당 하나의 하위 요소만 있습니다. 가
가로 목록의 높이는 한 행뿐이고 가장 큰 하위 요소의 높이입니다.
패딩이 있습니다. LinearLayout는 텍스트 사이의 여백을 준수합니다.
하위 요소, 중력(오른쪽, 중앙, 왼쪽)
정렬해야 합니다.
레이아웃 가중치
LinearLayout는 또한 다음에 가중치를 할당하는 것을 지원합니다.
장애를 가진 개별 어린이를
android:layout_weight
속성의 값을 제공합니다. 이 속성은 값을
그것이 화면의 공간을 얼마나 차지하는지를 나타냅니다. 가중치 값이 클수록
상위 뷰의 나머지 공간을 채웁니다. 하위 뷰에서는 가중치를 지정할 수 있음
뷰 그룹의 나머지 공간은 하위 요소에 할당됩니다.
선언된 체중에 비례합니다. 기본 가중치는 0입니다.
균등 분포
각 하위 요소가 동일한 공간을 사용하는 선형 레이아웃을 만들려는 경우
화면에서
android:layout_height 드림
세로 레이아웃의 경우 "0dp"로 변환하거나
android:layout_width
각 뷰의 값을 가로 레이아웃의 "0dp"로 설정합니다. 그런 다음
각 보기의 android:layout_weight를 "1"로 설정합니다.
비균등 분포
하위 요소가 서로 다른 요소를 사용하는 선형 레이아웃을 만들 수도 있습니다.
줄일 수 있습니다. 다음 예를 고려하세요.
텍스트 필드가 세 개 있다고 가정해 보겠습니다. 두 개의 텍스트 필드는 가중치 값이 1이고
세 번째는 기본 가중치 값 0입니다. 세 번째 텍스트 입력란은
가중치 값이 0이면 콘텐츠에 필요한 영역만 차지합니다. 다른
가중치 값이 1인 두 개의 텍스트 필드는
세 필드의 콘텐츠가 모두 측정된 후 남은 공간이 측정됩니다.
두 개의 가중치 값이 1인 텍스트 필드 3개가 있다면
세 번째 요소의 가중치가 2이면
측정되는 세 필드의 콘텐츠는 다음과 같이 할당됩니다.
가중치 값이 2인 필드와
가중치 값이 1인 필드로 구성됩니다.
다음 그림과 코드 스니펫은 레이아웃 가중치가
"메시지 보내 줘" 있습니다. To 필드, Subject 줄, Send 버튼은 각각 필요한 높이만 차지합니다. 메시지 영역
액티비티 높이의 나머지 부분을 차지합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Create a linear layout\n\nTry the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn how to work with layouts in Compose. \n[Column or Row →](/jetpack/compose/layouts/basics) \n\n[LinearLayout](/reference/android/widget/LinearLayout)\nis a view group that aligns all children in a single direction, vertically or\nhorizontally. You can specify the layout direction with the\n[`android:orientation`](/reference/android/widget/LinearLayout#attr_android:orientation)\nattribute.\n| **Note:** For better performance and tooling support, [build your layout with\n| ConstraintLayout](/training/constraint-layout). Learn more about advantages of using `ConstraintLayout` by reading [Understanding\n| the performance benefits of ConstraintLayout](https://android-developers.googleblog.com/2017/08/understanding-performance-benefits-of.html).\n**Figure 1.** A `LinearLayout` with three horizontally oriented children.\n\nAll children of a `LinearLayout` are stacked one after the other,\nso a vertical list only has one child per row, no matter how wide they are. A\nhorizontal list is only one row high, and it's the height of the tallest child,\nplus padding. A `LinearLayout` respects *margins* between\nchildren, and the *gravity*---right, center, or left\nalignment---of each child.\n\nLayout weight\n-------------\n\n`LinearLayout` also supports assigning a *weight* to\nindividual children with the\n[`android:layout_weight`](/reference/android/widget/LinearLayout.LayoutParams#attr_android:layout_weight)\nattribute. This attribute assigns an \"importance\" value to a view in terms of\nhow much space it occupies on the screen. A larger weight value lets it expand\nto fill the remaining space in the parent view. Child views can specify a weight\nvalue, and any remaining space in the view group is assigned to children\nproportionately, based on their declared weight. The default weight is zero.\n\n### Equal distribution\n\nTo create a linear layout in which each child uses the same amount of space\non the screen, set the\n[`android:layout_height`](/reference/android/view/ViewGroup.LayoutParams#attr_android:layout_height)\nof each view to `\"0dp\"` for a vertical layout, or the\n[`android:layout_width`](/reference/android/view/ViewGroup.LayoutParams#attr_android:layout_width)\nof each view to `\"0dp\"` for a horizontal layout. Then set the\n`android:layout_weight` of each view to `\"1\"`.\n\n### Unequal distribution\n\nYou can also create linear layouts where the child elements use different\namounts of space on the screen. Consider the following examples:\n\n- Suppose you have three text fields: two with a weight value of 1, and a third with the default weight value of 0. The third text field, with the weight value of 0, occupies only the area required by its content. The other two text fields, with the weight value of 1, expand equally to fill the space that remains after the contents of all three fields are measured.\n- If instead you have three text fields where two have a weight value of 1 and the third has a weight of 2, then the space that remains after the contents of all three fields are measured is allocated as follows: half to the field with the weight value of 2, and half divided equally between the fields with the weight value of 1.\n\nThe following figure and code snippet show how layout weights might work in a\n\"send message\" activity. The **To** field, **Subject** line, and\n**Send** button each take up only the height they need. The message area\ntakes up the rest of the activity's height.\n**Figure 2.** Three text fields and a button in a vertically oriented `LinearLayout`. \n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:paddingLeft=\"16dp\"\n android:paddingRight=\"16dp\"\n android:orientation=\"vertical\" \u003e\n \u003cEditText\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:hint=\"@string/to\" /\u003e\n \u003cEditText\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:hint=\"@string/subject\" /\u003e\n \u003cEditText\n android:layout_width=\"match_parent\"\n android:layout_height=\"0dp\"\n android:layout_weight=\"1\"\n android:gravity=\"top\"\n android:hint=\"@string/message\" /\u003e\n \u003cButton\n android:layout_width=\"100dp\"\n android:layout_height=\"wrap_content\"\n android:layout_gravity=\"end\"\n android:text=\"@string/send\" /\u003e\n\u003c/LinearLayout\u003e\n```\n\nFor details about the attributes available to each child view of a\n`LinearLayout`, see\n[LinearLayout.LayoutParams](/reference/android/widget/LinearLayout.LayoutParams)."]]