WebView 设置背景透明

先看效果;

[img]http://dl.iteye.com/upload/attachment/501468/8048cf17-5857-3ffd-86c1-222959e766af.png[/img]


代码:
布局:
<?xml version="1.0" encoding="UTF-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/webtest"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<WebView android:id="@+id/web"
android:background="@drawable/back_nocorner"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</AbsoluteLayout>


java代码:
public class MainActivity extends Activity{
private Button button;
private MyView view;
WebView webView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView)findViewById(R.id.web);
//Drawable = getResources().getDrawable(R.drawable.back_nocorner);
// webView.setBackgroundDrawable(getResources().getDrawable(R.drawable.back_nocorner));
webView.setBackgroundColor(0);
webView.loadUrl("file:///android_asset/storytext_py.html");
}
}


修改后:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/webtest"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<WebView android:id="@+id/web"
android:background="@drawable/back_nocorner"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_width="280dp"
android:layout_height="60dp"/>
</FrameLayout>


[img]http://dl.iteye.com/upload/attachment/501471/be429d3c-b052-38a3-a653-30e5cf7710eb.png[/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值