Chinaunix首页 | 论坛 | 博客
  • 博客访问: 903986
  • 博文数量: 75
  • 博客积分: 6236
  • 博客等级: 准将
  • 技术积分: 726
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-03 14:43
文章分类

全部博文(75)

文章存档

2019年(1)

2018年(6)

2017年(4)

2015年(1)

2014年(9)

2013年(1)

2012年(3)

2011年(9)

2010年(3)

2009年(2)

2008年(4)

2007年(24)

2006年(8)

我的朋友

分类: Android平台

2013-12-18 14:10:28

基本思路是:
1、先将layout文件中的 WebView控件取消硬件加速 android:layerType="software",(以确保第2步有效)
2、在Java代码中,将WebView控件背景色设为透明 web.setBackgroundColor(0);
3、获取一个圆角的Bitmap实例(网上有大把的实现方法);
4、通过 Bitmap实例获取一个 BitmapDrawable实例 BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
5、将 BitmapDrawable实例 BitmapDrawable 设置成WebView控件的背景 web.setBackground(bitmapDrawable);

不过,由于 web.setBackground 是 Android v4.1.2 (API Level 16)才开始支持,因此,这个功能也只能在 API Level 16及其以上实现。
阅读(6457) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~