Beautiful and customizable Android Activity that shows web pages within an app.

Min SDK   7
Latest Commit   2016-12-27 17:41:57
License   unknown

Github   https://github.com/TheFinestArtist/FinestWebView-Android

         

使用APP客户端扫描二维码运行Demo


...

TheFinestArtist
TheFinestArtist, Google Inc.
Seoul, Korea

http://thefinestartist.com

         

类似的还有....
cardslib Android Library to build a UI Card
Stepper-Touch Stepper Touch for Android based on MaterialUp submission
ShowcaseView Highlight the best bits of your app to users quickly, simply, and cool...ly
README

README.md

FinestWebView

Android Arsenal Platform API License

Beautiful and customizable Android Activity that shows web pages within an app.

  • Builder pattern
  • Material design & Pre-made icons
  • Webview listeners
  • Custom themes & Custom transition animations
  • Support collapsing toolbar & contextual actionbar
  • SwipeRefreshLayout & Progressbar
  • Device rotation
  • Gradient divider
  • Custom typeface & translation
  • Supports Right to Left

Screenshots

Default theme & Copied to clipboard

Back and forward & More options

FinestWebView Demo Video - YouTube

Youtube

Sample Project

You can download the latest sample APK from this repo here: sample-release.apk

It's also on Google Play:

Get it on Google Play

Getting started

Gradle Dependency (jcenter)

Easily reference the library in your Android projects using this dependency in your module's build.gradle file.

dependencies {
    compile 'com.thefinestartist:finestwebview:1.2.7'
}

Manifest Settings

FinestWebView is basically and Android activity with webview, toolbar and etc.
You have to add FinestWebViewActivity in your AndroidManifest.xml

<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" />

Basic WebView

new FinestWebView.Builder(activity).show(url);

Customization

There are 2 ways to customize FinestWebView.

1. Using Themes

You can use your own Theme for FinestWebView. If you want to use pre-defined theme, use android:theme="@style/FinestWebViewTheme" or android:theme="@style/FinestWebViewTheme.Fullscreen"

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:textColorPrimary">@color/primary_text</item>
    <item name="android:textColorSecondary">@color/secondary_text</item>
    <item name="windowActionModeOverlay">true</item>
</style>
<activity
    android:name="com.thefinestartist.finestwebview.FinestWebViewActivity"
    android:theme="@style/AppTheme.NoActionBar" />

2. Builder Options

Constructors

Builder(@NonNull Activity activity);
// If you use context instead of activity, FinestWebView enter animation won't work
Builder(@NonNull Context context);

Load data or Show url

load(@StringRes int dataRes);
load(String data);
load(String data, String mimeType, String encoding);

show(@StringRes int urlRes);
show(@NonNull String url);

WebView Listener Options

setWebViewListener(WebViewListener listener);
addWebViewListener(WebViewListener listener);
removeWebViewListener(WebViewListener listener);

Right to Left Options

rtl(boolean rtl);

Theme Options

theme(@StyleRes int theme);

StatusBar Options

statusBarColor(@ColorInt int color);
statusBarColorRes(@ColorRes int color);

Toolbar Options

toolbarColor(@ColorInt int color);
toolbarColorRes(@ColorRes int color);
toolbarScrollFlags(@ScrollFlags int flags);

Icon Options

iconDefaultColor(@ColorInt int color);
iconDefaultColorRes(@ColorRes int color);
iconDisabledColor(@ColorInt int color);
iconDisabledColorRes(@ColorRes int colorRes);
iconPressedColor(@ColorInt int color);
iconPressedColorRes(@ColorRes int colorRes);
iconSelector(@DrawableRes int selectorRes);

Icon Options

showIconClose(boolean showIconClose);
disableIconClose(boolean disableIconClose);
showIconBack(boolean showIconBack);
disableIconBack(boolean disableIconBack);
showIconForward(boolean showIconForward);
disableIconForward(boolean disableIconForward);
showIconMenu(boolean showIconMenu);
disableIconMenu(boolean disableIconMenu);

SwipeRefreshLayout Options

showSwipeRefreshLayout(boolean showSwipeRefreshLayout);
swipeRefreshColor(@ColorInt int color);
swipeRefreshColorRes(@ColorRes int colorRes);
swipeRefreshColors(int[] colors);
swipeRefreshColorsRes(@ArrayRes int colorsRes);

Divider Options

showDivider(boolean showDivider);
gradientDivider(boolean gradientDivider);
dividerColor(@ColorInt int color);
dividerColorRes(@ColorRes int colorRes);
dividerHeight(float height);
dividerHeight(int height);
dividerHeightRes(@DimenRes int height);

ProgressBar Options

showProgressBar(boolean showProgressBar);
progressBarColor(@ColorInt int color);
progressBarColorRes(@ColorRes int colorRes);
progressBarHeight(float height);
progressBarHeight(int height);
progressBarHeightRes(@DimenRes int height);
progressBarPosition(@NonNull Position position);

Title Options

titleDefault(@NonNull String title);
titleDefaultRes(@StringRes int stringRes);
updateTitleFromHtml(boolean updateTitleFromHtml);
titleSize(float titleSize);
titleSize(int titleSize);
titleSizeRes(@DimenRes int titleSize);
titleFont(String titleFont);
titleColor(@ColorInt int color);
titleColorRes(@ColorRes int colorRes);

Url Options

showUrl(boolean showUrl);
urlSize(float urlSize);
urlSize(int urlSize);
urlSizeRes(@DimenRes int urlSize);
urlFont(String urlFont);
urlColor(@ColorInt int color);
urlColorRes(@ColorRes int colorRes);

Menu Options

menuColor(@ColorInt int color);
menuColorRes(@ColorRes int colorRes);
menuDropShadowColor(@ColorInt int color);
menuDropShadowColorRes(@ColorRes int colorRes);
menuDropShadowSize(float menuDropShadowSize);
menuDropShadowSize(int menuDropShadowSize);
menuDropShadowSizeRes(@DimenRes int menuDropShadowSize);
menuSelector(@DrawableRes int selectorRes);

menuTextSize(float menuTextSize);
menuTextSize(int menuTextSize);
menuTextSizeRes(@DimenRes int menuTextSize);
menuTextFont(String menuTextFont);
menuTextColor(@ColorInt int color);
menuTextColorRes(@ColorRes int colorRes);

menuTextGravity(int gravity);
menuTextPaddingLeft(float menuTextPaddingLeft);
menuTextPaddingLeft(int menuTextPaddingLeft);
menuTextPaddingLeftRes(@DimenRes int menuTextPaddingLeft);
menuTextPaddingRight(float menuTextPaddingRight);
menuTextPaddingRight(int menuTextPaddingRight);
menuTextPaddingRightRes(@DimenRes int menuTextPaddingRight);

showMenuRefresh(boolean showMenuRefresh);
stringResRefresh(@StringRes int stringResRefresh);
showMenuFind(boolean showMenuFind);
stringResFind(@StringRes int stringResFind);
showMenuShareVia(boolean showMenuShareVia);
stringResShareVia(@StringRes int stringResShareVia);
showMenuCopyLink(boolean showMenuCopyLink);
stringResCopyLink(@StringRes int stringResCopyLink);
showMenuOpenWith(boolean showMenuOpenWith);
stringResOpenWith(@StringRes int stringResOpenWith);

More Options

setCustomAnimations(@AnimRes int animationOpenEnter,
                    @AnimRes int animationOpenExit,
                    @AnimRes int animationCloseEnter,
                    @AnimRes int animationCloseExit)
backPressToClose(boolean backPressToClose);
stringResCopiedToClipboard(@StringRes int stringResCopiedToClipboard);

WebView Options

webViewSupportZoom(boolean webViewSupportZoom);
webViewMediaPlaybackRequiresUserGesture (boolean webViewMediaPlaybackRequiresUserGesture);
webViewBuiltInZoomControls (boolean webViewBuiltInZoomControls);
webViewDisplayZoomControls (boolean webViewDisplayZoomControls);
webViewAllowFileAccess (boolean webViewAllowFileAccess);
webViewAllowContentAccess (boolean webViewAllowContentAccess);
webViewLoadWithOverviewMode (boolean webViewLoadWithOverviewMode);
webViewSaveFormData (boolean webViewSaveFormData);
webViewTextZoom (int webViewTextZoom);
webViewUseWideViewPort (boolean webViewUseWideViewPort);
webViewSupportMultipleWindows (boolean webViewSupportMultipleWindows);
webViewLayoutAlgorithm (WebSettings.LayoutAlgorithm webViewLayoutAlgorithm);
webViewStandardFontFamily (String webViewStandardFontFamily);
webViewFixedFontFamily (String webViewFixedFontFamily);
webViewSansSerifFontFamily (String webViewSansSerifFontFamily);
webViewSerifFontFamily (String webViewSerifFontFamily);
webViewCursiveFontFamily (String webViewCursiveFontFamily);
webViewFantasyFontFamily (String webViewFantasyFontFamily);
webViewMinimumFontSize (int webViewMinimumFontSize);
webViewMinimumLogicalFontSize (int webViewMinimumLogicalFontSize);
webViewDefaultFontSize (int webViewDefaultFontSize);
webViewDefaultFixedFontSize (int webViewDefaultFixedFontSize);
webViewLoadsImagesAutomatically (boolean webViewLoadsImagesAutomatically);
webViewBlockNetworkImage (boolean webViewBlockNetworkImage);
webViewBlockNetworkLoads (boolean webViewBlockNetworkLoads);
webViewJavaScriptEnabled (boolean webViewJavaScriptEnabled);
webViewAllowUniversalAccessFromFileURLs (boolean webViewAllowUniversalAccessFromFileURLs);
webViewAllowFileAccessFromFileURLs (boolean webViewAllowFileAccessFromFileURLs);
webViewGeolocationDatabasePath (String webViewGeolocationDatabasePath);
webViewAppCacheEnabled (boolean webViewAppCacheEnabled);
webViewAppCachePath (String webViewAppCachePath);
webViewDatabaseEnabled (boolean webViewDatabaseEnabled);
webViewDomStorageEnabled (boolean webViewDomStorageEnabled);
webViewGeolocationEnabled (boolean webViewGeolocationEnabled);
webViewJavaScriptCanOpenWindowsAutomatically (boolean webViewJavaScriptCanOpenWindowsAutomatically);
webViewDefaultTextEncodingName (String webViewDefaultTextEncodingName);
webViewUserAgentString (String webViewUserAgentString);
webViewNeedInitialFocus (boolean webViewNeedInitialFocus);
webViewCacheMode (int webViewCacheMode);
webViewMixedContentMode (int webViewMixedContentMode);
webViewOffscreenPreRaster (boolean webViewOffscreenPreRaster);

injectJavaScript(String injectJavaScript);

Builder Pattern

new FinestWebView.Builder(activity)
    .titleDefault("Default Title")
    .toolbarScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS)
    .gradientDivider(false)
    .dividerHeight(100)
    .toolbarColorRes(R.color.accent)
    .dividerColorRes(R.color.black_30)
    .iconDefaultColorRes(R.color.accent)
    .iconDisabledColorRes(R.color.gray)
    .iconPressedColorRes(R.color.black)
    .progressBarHeight(DipPixelHelper.getPixel(context, 3))
    .progressBarColorRes(R.color.accent)
    .backPressToClose(false)
    .setCustomAnimations(R.anim.activity_open_enter, R.anim.activity_open_exit, R.anim.activity_close_enter, R.anim.activity_close_exit)
    .show(url);

More customizations