2012-05-31 71 views
1

我有一個webview的佈局,我想使webview的背景顏色透明。我嘗試了一些不同的方式和Android中WebView中的半透明背景顏色

webView.setBackgroundColor(Color.argb(128, 0, 0, 0));

對我來說這一個工作。但問題是我不能使整個webview透明,只有webview的右側有一個小條透明背景,其餘的webview有黑色背景。 任何使整個webview透明的想法? 在這裏我上傳了截圖,你可以查看我的xml和java代碼。 ,如果你也知道如何使視圖具有半徑邊界,它也可以很好。由於

protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.aboutus); 

    String webData = StringHelper.addSlashes("<font color=\"#6495ed\">TEST</font>"); 

    webView = (WebView) findViewById(R.id.webview); 
    webView.loadData(webData, "text/html", "UTF-8"); 
    webView.setBackgroundColor(Color.argb(128, 0, 0, 0)); 
} 

<?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" 
android:background="@drawable/bg2" 
android:weightSum="100" > 

<ImageView 
    android:id="@+id/about_us_header_image" 
    android:layout_height="0dip" 
    android:layout_width="match_parent" 
    android:background="@drawable/header" 
    android:layout_weight="20" 
    android:visibility="invisible" 
    /> 

<WebView 
    android:id="@+id/webview" 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_weight="80" 
    android:layout_margin="20dp" 
    /> 
</LinearLayout> 

enter image description here

+1

嘗試在HTML頁面中設置透明背景顏色。 – Steelight

+0

我不確定這會適用於我的情況。因爲我將從網頁中動態獲取HTML。 – osayilgan

+0

它至少會讓你知道問題是否存在。 – Steelight

回答

1

在計算器搜索後,我已經看到了它的不僅​​有這個問題,我發現了一個變通的devies 2.2xx和2.3xx這裏是下面的鏈接。 。

Here是鏈接到我的解決方案。