WebView setBackgroundColor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for WebView setBackgroundColor method.

This code example shows how to use the following methods:getContext, loadDataWithBaseURL, setBackgroundColor, setWebViewClient
	} 
	 
	 
    private void setup(){ 
    	 
    	String source = getSource(wv.getContext());
    	String html = source.replace("@src", url).replace("@color", Integer.toHexString(color));
    	 
    	wv.setWebViewClient(this);
    	 
    	//wv.setInitialScale(100); 
    	wv.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);
    	wv.setBackgroundColor(color);
    	 
    } 
	 
    private void done(WebView view){
    	if(progress != null){
			//progress.setVisibility(View.GONE); 
			view.setVisibility(View.VISIBLE);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSettings, loadUrl, setBackgroundColor
		@Override 
		public void onCreate(Bundle state)
		{ 
			super.onCreate(state);
 
			WebView view = new WebView(this);
			view.getSettings().setJavaScriptEnabled(true);
			view.loadUrl("file:///android_asset/about.html");
			view.setBackgroundColor(Color.TRANSPARENT);
			setContentView(view);
		} 
	} 
 
	@TargetApi(11) 
	public static class AboutFragment extends WebViewFragment {
		@Override 
		public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{ 
			WebView view = (WebView)super.onCreateView(inflater, container, savedInstanceState);
			view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSettings, loadUrl, setBackgroundColor, setWebChromeClient
 
	@SuppressLint("SetJavaScriptEnabled") 
	public static void displayArticle(WebView webView, Article article, Context context) {
		String styles = "iframe, img { width: 100%; }";
		if (isDarkTheme(context)) {
			webView.setBackgroundColor(Color.BLACK);
			styles += "body { background-color: #000000; color: #F6F6F6; } a { color: #0099FF; }";
		} 
		String html = String.format("<html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"http://cdn.uservoice.com/stylesheets/vendor/typeset.css\"/><style>%s</style></head><body class=\"typeset\" style=\"font-family: sans-serif; margin: 1em\"><h3>%s</h3>%s</body></html>", styles, article.getTitle(), article.getHtml());
		webView.setWebChromeClient(new WebChromeClient());
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setPluginState(PluginState.ON);
		webView.loadUrl(String.format("data:text/html;charset=utf-8,%s", Uri.encode(html)));
	} 
 
    public static boolean isDarkTheme(Context context) {
        TypedValue tv = new TypedValue();
        float [] hsv =  new float[3];
        context.getTheme().resolveAttribute(android.R.attr.textColorPrimary, tv, true);
        Color.colorToHSV(context.getResources().getColor(tv.resourceId), hsv);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setId, setBackgroundColor, setLayoutParams
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getContext, loadDataWithBaseURL, setBackgroundColor, setWebViewClient
	} 
	 
	 
    private void setup(){ 
    	 
    	String source = getSource(wv.getContext());
    	String html = source.replace("@src", url).replace("@color", Integer.toHexString(color));
    	 
    	wv.setWebViewClient(this);
    	 
    	//wv.setInitialScale(100); 
    	wv.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);
    	wv.setBackgroundColor(color);
    	 
    } 
	 
    private void done(WebView view){
    	if(progress != null){
			//progress.setVisibility(View.GONE); 
			view.setVisibility(View.VISIBLE);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadDataWithBaseURL, setBackgroundColor, setScrollBarStyle
	 * @param context 
	 * @param html 
	 */ 
	public static void showHtml(final Context context, final String html) {
		AlertDialog.Builder moreDetailsDialog = null;
		final WebView webView = new WebView(context);
		final ScrollView scrollView = new ScrollView(context);
 
		webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
		webView.setBackgroundColor(Color.WHITE);
		webView.loadDataWithBaseURL("fake://not/needed", html, "text/html", "UTF-8", null); // Encoding
																							// fix 
																							// for 
																							// Android 
																							// 3.x 
																							// / 
																							// 4.x 
		scrollView.addView(webView);
 
		moreDetailsDialog = new AlertDialog.Builder(context);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setHorizontalScrollBarEnabled, setVerticalScrollBarEnabled, getSettings, setBackgroundColor, setWebChromeClient
	 * @param context 
	 */ 
	public OpenxAdView(Context context) {
		super(context);
		this.res = context.getResources();
		this.webView = new WebView(context);
		initWebView(); 
	} 
 
	/** 
	 * Initialize widget. If delivery_url and zone_id attributes were set in 
	 * layout file, ad will be loaded automatically. 
	 *  
	 * @param context 
	 * @param attrs 
	 * @param defStyle 
	 */ 
	public OpenxAdView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		this.res = context.getResources();

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:loadUrl, setBackgroundColor, setScrollBarStyle, setWebViewClient
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
 
        mWebView = new WebView(this);
        mWebView.setBackgroundColor(0xFFEEEEEE);
        mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        mWebView.setWebViewClient(new WebViewClient() {
            @Override 
            public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
                view.loadUrl(url);
                return true; 
            } 
        }); 
        mWebView.loadUrl("file:///android_asset/licenses.html");
 
        setContentView(mWebView);
    } 
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setHorizontalScrollBarEnabled, setOnTouchListener, setScrollContainer, setVerticalScrollBarEnabled, getSettings
This code example shows how to use the following methods:addJavascriptInterface, clearView, getSettings, loadUrl, setBackgroundColor
		this.useTransparentBackground = useTransparentBackground;
	} 
 
	@Override 
	public View getView(final Context context) {
		WebView w = new WebView(context);
		w.getSettings().setBuiltInZoomControls(useDefaultZoomControls);
		if (useTransparentBackground)
			w.setBackgroundColor(0x00000000);
		w.getSettings().setJavaScriptEnabled(true);
 
		w.setWebChromeClient(new WebChromeClient() {
			public void onProgressChanged(WebView view, int progress) {
				onPageLoadProgress(progress * 100);
			} 
		}); 
 
		w.setWebViewClient(new WebViewClient() {
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				if (url != null && url.startsWith("market://")) {

6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related WebView setBackgroundColor Questions & Answers:

setBackgroundColor Method Overview
Sets the background color for this view.
See Code Examples for other Android WebView Methods: