繁体   English   中英

Android WebView中的半透明背景色

[英]Semi-Transparent background color in WebView in Android

我在一个布局中有一个Webview,我想使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>

在此处输入图片说明

在搜索stackoverflow之后,我发现它不仅存在此问题,而且我找到了针对设备2.2xx和2.3xx的解决方法,这是下面的链接。

是我的解决方案的链接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM