나는 버튼과 레이아웃을 달성하기 위해 노력하고 EditText
과를 Buttton
화면 상단하는에 TextView
바닥에서, a는 ListView
수직으로 뒤쪽의 공간을 채 웁니다. 어젯밤 나는 ListView
앱의 처리를 테스트하기 위해에 절대 높이를 사용하는 것을 제외하고는 다소 정확했습니다 .
Android Studio를 닫고 지금 열어 본 이후 무슨 일이 있었는지 모르겠습니다. 마술, Git repo에 대한 것, 또는 무의식적 인 변화 일 수도 있지만, 이제는 ListView
디스플레이에서 무한히 아래로 확장 되는 것 같습니다. ,이 사진에서 주황색 윤곽선으로 강조 표시 :
다양한 layout_height
가치를 시도 50dp
해봤는데 위의 사진입니다. 낮게 10dp
도 차이가 없으며 상단 파란색 앵커 라인에서 마우스를 사용하여 더 작게 드래그하면 차이가 없습니다.
여기서 무엇이 잘못되었으며이 문제를 해결하기 위해 어디에서 찾아야합니까?
다음은 레이아웃에 대한 XML입니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_centerHorizontal="true"
tools:context="com.bradykelly.heavyweights.MainActivity"
android:weightSum="1">
<TextView
android:layout_width="match_parent"
android:layout_height="10dp"
android:text="@string/adjustment_label"
android:id="@+id/scale_text_view_label"
android:background="@color/colorPrimaryDark"
android:textColor="@color/textColorPrimary"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:textAlignment="center"
android:gravity="center"
android:textSize="20sp"
android:textStyle="bold"
android:layout_weight="0.09"
android:height="10dp"/>
<EditText
android:id="@+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/text_view_border"
android:layout_marginTop="5dp"
android:ems="10"
android:inputType="text"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:enabled="true"
android:focusable="true"/>
<Button
android:id="@+id/processButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:text="@string/process_file_text" />
<ListView
android:cacheColorHint="#00000000"
android:scrollbars="none"
android:fadingEdge="vertical"
android:soundEffectsEnabled="true"
android:dividerHeight="1dp"
android:padding="5dp"
android:smoothScrollbar="true"
android:layout_weight="50"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:drawSelectorOnTop="false"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/textView3"
android:background="@drawable/text_view_border"
android:layout_marginLeft="20dp"
android:textAlignment="center"
android:gravity="center"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginRight="20dp"
android:layout_marginBottom="-20dp"
/>
</LinearLayout>
layout_weight
속성을 사용하여 레이아웃을 약간 변경 했습니다. 아래xml
코드를Layout
. 아래layout
를 사용 하면에서List view
첨부 한 화면에 맞는 것을 보여줍니다screen shot
.당신이 준 때문에
List view height=50
또한 당신이 준weight
이 문제가 발생할 수 있도록.
You not need to define height when you are using weight property in your layout
.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:weightSum="10">
<TextView
android:id="@+id/scale_text_view_label"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:background="@color/colorPrimaryDark"
android:gravity="center"
android:text="Adjustment Label"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:textStyle="bold" />
<EditText
android:id="@+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:ems="10"
android:enabled="true"
android:focusable="true"
android:inputType="text" />
<Button
android:id="@+id/processButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:text="Process" />
<ListView
android:id="@+id/ListView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:layout_weight="8"
android:cacheColorHint="#00000000"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false"
android:fadingEdge="vertical"
android:padding="5dp"
android:scrollbars="none"
android:smoothScrollbar="true"
android:soundEffectsEnabled="true" />
<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="-20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:gravity="center"
android:text="Testeing"
android:textAlignment="center"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다