2011-01-18 7 views
0

내 XML : SDK 3 (1.5) 및 SDK에서안드로이드 : 상대 레이아웃 문제

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <TextView android:id="@+id/Title" android:text="title" 
     android:layout_width="fill_parent" android:layout_height="wrap_content" 
     android:singleLine="true" android:layout_alignParentTop="true" /> 
    <EditText android:id="@+id/ReplyText" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:gravity="top" 
     android:layout_below="@+id/Title" android:layout_above="@+id/Save" /> 
<!-- <WebView android:id="@+id/webview" android:layout_width="fill_parent"--> 
<!--  android:layout_height="fill_parent" android:layout_below="@+id/Title"--> 
<!--  android:layout_above="@+id/Save"/>--> 
    <Button android:text="Save" android:id="@+id/Save" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" /> 
</RelativeLayout> 

출력 9 (2.3) alt text

질문 : 왜 글고 1.5 버전에서 표시되지 않는 이유는 무엇입니까? 그것은 두 버전에서 완벽하게 웹보기를 표시

WebView mWebView = (WebView) findViewById(R.id.webview); 
mWebView.getSettings().setJavaScriptEnabled(true); 
mWebView.loadData("test", "text/html", "utf-8"); 
mWebView.setWebViewClient(new WebViewClient()); 

: 나는에서 onCreate 메서드에서 추가 약간의 코드를 웹보기 와 글고 치기를 교체하는 경우 때문에

,이 용액이 있어야합니다.

목표 : 머리글과 바닥 글 요소를 그림과 같이 표시하고 가운데 요소의 나머지 높이를 전체 높이/너비로 설정하고 싶습니다.

android:layout_below="@+id/Title" android:layout_above="@+id/Save" 

@+id 수단은 새 ID를 추가하고,이 경우에 당신은 (이미 정의 된 ID에 다스 려하는 당신이 android:id="@+id/Title"에서 그들을 정의 :이 문제가 될 수 있지만,이 잘못된 경우

답변

4

확실하지 않음 및 android:id="@+id/Save"). 구성 요소 자체 전에 ID를 참조 할 때

또한 나는

내가 전체를 작성합니다 (이 경우 당신이 버튼 위에있는 및 버튼이 나중에 정의하는 글고 치기에 말) 과거에 몇 가지 문제가 있었다 이 같은 레이아웃 : 깊이 레이어가 문제가 될 수 있습니다

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <TextView android:id="@+id/Title" 
     android:text="title" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:singleLine="true" 
     android:layout_alignParentTop="true" /> 
    <Button android:text="Save" 
     android:id="@+id/Save" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" /> 
    <EditText android:id="@+id/ReplyText" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="top" 
     android:layout_below="@id/Title" 
     android:layout_above="@id/Save" /> 

</RelativeLayout> 
-1

경우이 같은 XML을 정의 할 수 있습니다 아이디가

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

<TextView android:id="@+id/Title" 
    android:text="title" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:singleLine="true" 
    android:layout_alignParentTop="true" /> 

<EditText android:id="@+id/ReplyText" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="top" 
     android:layout_below="@id/Title" 
     android:layout_above="@+id/Save" /> 

    <Button android:text="Save" 
     android:id="@id/Save" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" /> 

</RelativeLayout> 

공지 것을 요소 자체는 추가되지 않고 첫 번째 언급이 있습니다.

android:layout_above="@+id/Save" /> 
    <Button android:text="Save" 
     android:id="@id/Save"