2012-12-12 2 views
0

상대 레이아웃과 배경을 사용할 때 문제가 있습니다. android:layout_height="match_parent"으로 설정했지만 배경이 모든 화면 (화면 높이)을 채우지 않고 하단 부분이 흰색으로 설정됩니다. 나는 화면 상단에 항목을 넣을 뿐이지 만이 동작이 맞다고 생각하지는 않습니다.상대 레이아웃의 배경이 모든 화면을 채우지 않습니다.

내 코드 XML :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="@drawable/background" > 


<TextView 
    android:id="@+id/title" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="@string/title" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="@dimen/dim_b" 
    android:layout_marginLeft="@dimen/dim_a" 
    android:layout_marginRight="@dimen/dim_a" /> 

<EditText 
    android:id="@+id/insert" 
    android:hint="@string/insert" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/title" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="@dimen/dim_c" 
    android:layout_marginLeft="@dimen/dim_a" 
    android:layout_marginRight="@dimen/dim_a" 
    android:inputType="textPassword" /> 

<Button 
    android:id="@+id/accept" 
    android:text="@string/accept" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/insert" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="@dimen/dim_d" 
    android:layout_marginLeft="@dimen/dim_a" 
    android:layout_marginRight="@dimen/dim_a" /> 

</RelativeLayout> 
+0

RelativeLayout의 모든 하위보기를 제거하여 시도해보십시오. 배경 drawable에 실수가있을 수 있습니다. – faylon

답변

0

시도 : 안드로이드 : layout_height = "fill_parent"

match_parent는 API 레벨 8 이상입니다.

+0

최소 SDK 버전 8을 사용하고 있습니다. 감사합니다. – LopezAgrela

2

1.First 당신이 "verticlal"방향 =이 필요한 이유 때문에 상대 레이아웃의 상단에서 제거를 사용하여 상대 레이아웃입니다

2.Edittext이 안드로이드와 같은 버튼 : layout_below = "@ + ID/title "notroid : layout_below ="@ id/title "

+0

나는 처음에는 동의하지만 두번째 것에 동의하지 않는다. 예를 들어, "insert"가 첫 번째 TextView의 ID이고 해당 ID로 이미 호출 되었기 때문에 android : layout_below = "@ id/insert"를 사용합니다. 귀하의 답변 주셔서 감사합니다! – LopezAgrela

관련 문제