2

私はこれについて髪を引っ張っていて、次のことを理解するためにウェブを数回解析しました。

WebView を埋め込む単純なアクティビティを使用しています。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/tables"
</LinearLayout>

ご覧のとおり、ドローアブル シェイプ ( android:background="@drawable/tables") を適用して、WebView の角が丸くなったり、境界線が描画されたりするようにしようとしています。

問題は、WebView が設定しようとしている外観を取得できないことです (角が丸くならないなど...)。

適用しようとしている形状のコード:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <solid   android:color="@color/fond_tables"/>
     <corners android:bottomRightRadius="10dp"
              android:bottomLeftRadius="10dp" 
              android:topLeftRadius="10dp"
              android:topRightRadius="10dp"/> 
     <stroke  android:width="3dp"
              android:color="@color/bordure_tables" />
</shape>

この問題の解決を手伝ってくれる人に感謝します。

前もって感謝します

アダム。

4

2 に答える 2

2

私も同じ問題に直面しました。後で、webView の背景を変更できないことがわかりました。レイアウトの背景を変更できます。私はこの方法を試してみましたが、うまくいきました。

<TableRow
    android:id="@+id/tableRow5"

    android:background="@drawable/fullshape"

    android:layout_width="300dp"
    android:layout_height="300dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="10dp" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="280dp"
        android:layout_height="280dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp" />

</TableRow>
于 2012-04-27T10:27:11.707 に答える
0
WebView webview = (WebView)findViewById(R.id.webView);        
webview.setBackgroundColor(0);

背景色を透明にすることで、webview はレイアウトの背景を使用します。

于 2015-03-02T14:06:10.107 に答える