2011-01-18 20 views
0

私の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" /> 
<!-- <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> 

SDK 3(1.5)での出力とSDK 9(2.3) alt text

質問:のEditTextが1.5バージョンでは表示されないのはなぜ?これは、両方のバージョンでは完全にWebViewのを表示し

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

:私はのonCreateメソッドで追加した少しのコードでWebViewの でのEditTextを置き換える場合ので

は、これの解決策が存在する必要があります。

ゴール:私はヘッダーとフッターの要素を図のように設定し、中間の要素は残りの部分の高さ/幅を完全に設定する必要があります。

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

@+id手段は、新しいIDを追加し、この場合には、あなたが(すでに定義されているIDに参照のうえいるあなたがandroid:id="@+id/Title"でそれらを定義します。これは問題かもしれないが、これは間違っている場合

答えて

4

わかりませんおよびandroid:id="@+id/Save")。コンポーネント自体の前にIDを参照するときに

はまた、私は、私はあなたの全体を記述します(この場合には、あなたがそれをボタンの上だとボタンが、後に定義されていることのEditTextで言う)

を過去にいくつかの問題がありましたこのようなレイアウト:深さの階層化が問題になることがあり

<?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を定義することができます: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" /> 

<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" 
関連する問題