속성은 TextView의 설명서에서 찾을 수없는 이유인데, 그 이유는이 속성이 나타나는 뷰의 일부가 아닙니다. (TextView는 ViewGroup이 아닙니다.) 부모보기에 대한 인수로 LayoutParams
이라고도합니다. 링크 된 페이지의 맨 위에있는 "알려진 서브 클래스"섹션을 살펴보십시오. 이것들은 ViewGroup
이 각 하위보기를 정렬하는 방법에 대한 지침이며, 각 부모 유형은 지원하는 레이아웃 옵션의 종류에 따라 다른 부모 유형을 인식 할 수 있습니다.
예를 들어 LinearLayout.LayoutParams
은 android:layout_weight
매개 변수를 지원합니다. LinearLayout
의 아이들은 모든 아이들이 측정 된 후에 나머지 공간의 비율을 요구하는 무게를 지정할 수 있습니다. 기본 너비가 0 인 두 형제 TextViews에 동일한 가중치를 부여하여 부모 내에서 사용 가능한 공간의 각 절반을 제공 할 수 있습니다.
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hello" />
<TextView android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="World" />
</LinearLayout>