스택 오버 플로우에 대한 "layout_gravity Bottom/Top in LinearLayout"과 관련하여 수백만 가지 질문과 대답이 있지만 여전히 문제를 해결하지 못했습니다.Android layout_gravity LinearLayout의 하단/상단
"맨 위를 맨 위로 올려주세요"라고 말한 EditText와 "맨 아래에 나를 넣어주세요"라고 쓰여있는 TextView를 배치하고 싶습니다. 내 꿈은 아주 기본이지만 나는 그것을 이룰 수 없다 !!
아무도 도와 줄 수 있습니까?
이
내 XML입니다 :<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="210dp"
android:background="@android:color/holo_green_light"
android:gravity="center_vertical"
android:orientation="vertical"
android:weightSum="1">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Please place me at very top" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@android:color/background_light"
android:text="TextView"
android:layout_weight="0.19" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="248dp"
android:layout_weight="0.70"
android:background="@color/colorAccent"
android:gravity="center_vertical"
android:orientation="vertical"
android:weightSum="1">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="62dp"
android:layout_gravity="top"
android:text="Button" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.16"
android:background="@android:color/background_light"
android:text="Please place me at very bottom" />
</LinearLayout>
</LinearLayout>
그리고 이것은 내 출력 :
ConstraintLayout을 사용하지 않는 이유는 무엇입니까? –
즉, 가중치를 사용할 때'android : layout_height'를 남겨 두는 것이 일반적으로 잘못되었습니다. 게다가 중심 중력을 적용했기 때문에 왜 위쪽이나 아래쪽에 있어야하는지 명확하지 않습니다. –
이것은 LinearLayout으로 생성 된 화면이며 모든 화면을 변경하지 않으려 고합니다.버튼 하나만 추가하고 싶습니다. (이 버튼은 하단에 위치해야합니다.) – Grcn