2011-03-09 66 views
2

我拉我的头发,并已解析网络多次了解以下内容。Android - WebView的问题

我用一个简单的活动中嵌入一个web视图:

<?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没有得到我想设置的任何apparence(没有圆角等)。

形状的代码,我想申请:

<?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> 

我将不胜感激的人谁可以帮我解决这个问题。

在此先感谢

亚当。

+0

任何人都可以帮助我吗? – 2011-03-11 07:46:07

回答

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> 
0
WebView webview = (WebView)findViewById(R.id.webView);   
webview.setBackgroundColor(0); 

通过应用背景色透明的,web视图将使用背景从布局。

+1

虽然这个答案可能是正确和有用的,但如果您在解释问题的过程中包含一些解释并解释它如何有助于解决问题,那么这是首选。如果存在导致其停止工作并且用户需要了解其曾经工作的变化(可能不相关),这在未来变得特别有用。 – 2015-03-03 01:26:06