2010-12-23 3 views
0

다음은 제 코드입니다. 한 줄의 텍스트 상자, 아래에 2 개의 단추가있는 여러 줄의 텍스트 상자가있는 인터페이스가 필요합니다. 여러 줄의 텍스트 상자가 버튼과 텍스트 상자를 렌더링 한 후에 사용 가능한 모든 공간을 차지하기를 원합니다. 이를 위해 기본 레이아웃 내부에 두 개의 LinearLayouts를 만들었습니다. 첫 번째 레이아웃에는 layout_width가 fill_parent로 설정된 세로 방향이 있습니다. 두 번째 것은 fill_parent와 함께 다시 수평입니다.Android - 선형 배치 배열, 예상대로 위치 지정하지 않음

첫 번째 텍스트 상자에는 parent를 채우기 위해 layout_height가 설정되어 있습니다. 두 번째 텍스트 상자에는 OK와 Cancel이라는 두 개의 텍스트 상자가 있습니다.

이 응용 프로그램을 실행할 때 UI가 표시되지만 버튼은 매우 작습니다 (약 5px 높이). 버튼 높이를 수동으로 설정해야합니다. 내가 여기서 잘못하고있는 것은 무엇인가. 나는 버튼 높이를 하드 코딩하고 싶지 않다.

감사

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> 
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> 
    <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Name"></TextView> 
    <EditText android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText> 
    <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Contents"></TextView> 
    <EditText android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="top" /> 
</LinearLayout> 
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> 
    <Button android:id="@+id/okbutt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="OK" android:layout_weight="1" /> 
    <Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Cancel" android:layout_weight="1" /> 
</LinearLayout> 

, 아룬

답변

2

나는 이것을 어떻게하는지 궁금해서, 그것을 시도하기로 결정했다. 이것은 내가 생각해 낸 것입니다 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
    android:id="@+id/buttons" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true"> 
    <Button 
     android:id="@+id/okbutt" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="OK" /> 
    <Button 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Cancel" /> 
    </LinearLayout> 
    <TextView 
    android:id="@+id/textview1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:text="Name" /> 
    <EditText 
    android:id="@+id/textedit1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/textview1" /> 
    <TextView 
    android:id="@+id/textview2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/textedit1" 
    android:text="Contents" /> 
    <EditText 
    android:id="@+id/textedit2" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@id/textview2" 
    android:layout_above="@id/buttons" /> 
</RelativeLayout> 

원하는대로하는 것 같습니다.

+0

감사합니다. svdree, 해결책이 작동합니다. 왜 내 것이 아닌지 궁금해. – Arun

0

당신이 상대 레이아웃 여기 대신 두 개의 선형 레이아웃을 사용할 수 있습니다, 내가 더 명확 UI를 줄 것이라 생각합니다. 유 수동으로 단지 버튼 작성된 텍스트의 높이, OK의 즉 높이를 증가 버튼의 높이를 증가시키고

안드로이드에 취소 할 경우
는 :

이 시도 TEXTSIZE를이 될 수있다 하나는 당신을 도와줍니다.