添加依赖
compile 'com.thefinestartist:finestwebview:1.0.6'
在AndroidManifest.xml文件中注册activity和声明权限
<uses-permission android:name="android.permission.INTERNET" />
<activity
android:name="com.thefinestartist.finestwebview.FinestWebViewActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="sensor"
android:theme="@style/FinestWebViewTheme.Light" />
直接使用默认的WebVIew
new FinestWebView.Builder(activity).show(url);
自定义选项
1.主题
new FinestWebView.Builder(this)
.theme(R.style.RedTheme)//修改主题
.titleDefault("Bless This Stuff")
.webViewBuiltInZoomControls(true)//使用内置控件 实现放大缩小功能
.webViewDisplayZoomControls(true)
.dividerHeight(0)
.gradientDivider(false)
.setCustomAnimations(R.anim.activity_open_enter, R.anim.activity_open_exit,
R.anim.activity_close_enter, R.anim.activity_close_exit)//动画
.injectJavaScript("javascript: document.getElementById('msg').innerHTML='Hello "
+ "TheFinestArtist"
+ "!';")
.show("http://www.blessthisstuff.com");
new FinestWebView.Builder(this).theme(R.style.FinestWebViewTheme)
.titleDefault("Vimeo")
.showUrl(false)
.statusBarColorRes(R.color.bluePrimaryDark)
.toolbarColorRes(R.color.bluePrimary)
.titleColorRes(R.color.finestWhite)
.urlColorRes(R.color.bluePrimaryLight)
.iconDefaultColorRes(R.color.finestWhite)
.progressBarColorRes(R.color.finestWhite)
.stringResCopiedToClipboard(R.string.copied_to_clipboard)
.stringResCopiedToClipboard(R.string.copied_to_clipboard)
.stringResCopiedToClipboard(R.string.copied_to_clipboard)
.showSwipeRefreshLayout(true)
.swipeRefreshColorRes(R.color.bluePrimaryDark)
.menuSelector(R.drawable.selector_light_theme)
.menuTextGravity(Gravity.CENTER)
.menuTextPaddingRightRes(R.dimen.defaultMenuTextPaddingLeft)
.dividerHeight(0)
.gradientDivider(false)
.setCustomAnimations(R.anim.slide_up, R.anim.hold, R.anim.hold, R.anim.slide_down)
.show("http://example.com");
new FinestWebView.Builder(this).theme(R.style.FinestWebViewTheme)
.titleDefault("Dribbble")
.toolbarScrollFlags(0)
.statusBarColorRes(R.color.blackPrimaryDark)
.toolbarColorRes(R.color.blackPrimary)
.titleColorRes(R.color.finestWhite)
.urlColorRes(R.color.blackPrimaryLight)
.iconDefaultColorRes(R.color.finestWhite)
.progressBarColorRes(R.color.finestWhite)
.swipeRefreshColorRes(R.color.blackPrimaryDark)
.menuSelector(R.drawable.selector_light_theme)
.menuTextGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT)
.menuTextPaddingRightRes(R.dimen.defaultMenuTextPaddingLeft)
.dividerHeight(0)
.gradientDivider(false)
// .setCustomAnimations(R.anim.slide_up, R.anim.hold, R.anim.hold, R.anim.slide_down)
.setCustomAnimations(R.anim.slide_left_in, R.anim.hold, R.anim.hold,
R.anim.slide_right_out)
// .setCustomAnimations(R.anim.fade_in_fast, R.anim.fade_out_medium, R.anim.fade_in_medium, R.anim.fade_out_fast)
.disableIconBack(true)
.disableIconClose(true)
.disableIconForward(true)
.disableIconMenu(true)
.show("https://dribbble.com");