0

Webビューの作成方法は、親レイアウトの幅と高さが-10dpで、背景画像は次の画像のようになります。

更新:青いボックスが画面です。黒いボックスは外側のレイアウト(@ + id /wrapper)で、赤いボックスはwebview(@ + id / webview)です。緑のボックスは他のレイアウトです。

デモ

次のコードで試しましたが、成功しません。Webビューのコンテンツが長すぎると、外側のレイアウトが伸びます。レイアウト内に固定サイズのWebビューが必要ですが、これを実現する方法がわかりません。

追伸 ブラックボックスの背景画像が全画面表示ではありません。

誰かが私にいくつかのヒントをくれますか?

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

    ... some other layout ...

    <LinearLayout
        android:id="@+id/wrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@drawable/wrapper_background" >

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dp" />
    </LinearLayout>

    ... some other layout ...

</RelativeLayout>
4

5 に答える 5

0

代わりにこのコードを使用してください

<LinearLayout
    android:id="@+id/wrapper"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/someOtherLayout"
    android:layout_centerInParent="true"
    android:background="@drawable/wrapper_background" >

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp" />
</LinearLayout>

<Some Other Layout
    android:id="@+id/someOtherLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" />

于 2013-01-16T05:41:24.290 に答える
0

使用する

android:padding="10dip" を webview の親に追加します。

于 2013-01-16T05:41:36.727 に答える
0

代わりにこのコードを使用してください

画像のようになります ここに画像の説明を入力

xml コード:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ic_launcher" >


  ... some other layout ...
    <LinearLayout
        android:id="@+id/wrapper"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        android:background="@drawable/ic_launcher" >

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dp" />
    </LinearLayout>
  ... some other layout ...


</RelativeLayout> 
于 2013-01-16T05:43:54.690 に答える
0

テストされていませんが、これを試すことができます:

<LinearLayout
        android:id="@+id/wrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:padding="10dp"
        android:background="@drawable/wrapper_background" >
于 2013-01-16T05:44:02.273 に答える
0

これを試してください:

  <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@drawable/common_background" >
... some other layout ...
<LinearLayout
    android:id="@+id/wrapper"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:padding="10dip"                   <---- Apply this in your layout.
    android:background="@drawable/wrapper_background" >
    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
         />
  </LinearLayout>
   ... some other layout ...
  </RelativeLayout>
于 2013-01-16T05:45:14.163 に答える