장치의 buttom에 레이아웃 버튼을 배치하려고합니다. PIC1에 따라레이아웃을 선언하여 여러 장치에서 ListView의 높이를 자동으로 조정하는 방법은 무엇입니까?
4.0 인치 장치에 배치하고, PIC2는 4.7 인치 장치
에 있으며 XML 코드가 시도됩니다.
버튼이 4.0 인치, 에서 올바른 위치에 배치되었지만 4.7 인치에 배치되지 않았습니다.
목록보기의 높이를 자동으로 조정하고 싶습니다.
어떻게 수행하나요?
[PIC1]
[PIC2]
여기서 XML 코드이다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/txtLabel2"
android:text="Buyed items"
android:textSize="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ListView
android:id="@+id/lsv_buyedList"
android:layout_width="match_parent"
android:layout_height="450dp">
</ListView>
<LinearLayout
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_sortById"
android:text="SortById"
android:textSize="15dp"
android:layout_width="110dp"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btn_sortByGrade"
android:text="SortByGrade"
android:textSize="15dp"
android:layout_width="110dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<Button
android:id="@+id/btn_confirm"
android:text="OK"
android:textSize="15dp"
android:layout_width="100dp"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
감사를
android:layout_height="450dp"
를 교체합니다. : D –이것이 맞습니다. –
허용되는 대답에 따라 LinearLayout을 사용하지 말라는 조언이 없습니다. RelativeLayout을 사용하십시오. 그런 다음 Button 섹션에 사용 된 2 개의 LinearLayouts가 없어도 동일한 결과를 얻을 수 있습니다. 각 추가 레이아웃은 하나의 렌더링주기를 강제합니다. 여기서하는 일은 전혀 성과가 없습니다. – Baschi