Changing the background of webview in android
-
I am developing an android game application,I have implemented all the screens.Now i want to change the webview background color,Can anybody guide me.Here is my xml file <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background"> <WebView android:id="@+id/webbrowser" android:layout_width="fill_parent" android:layout_height="345px" android:layout_marginTop="46px"/> <Button android:id="@+id/Btn" android:background="@drawable/back_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="109px" android:layout_marginTop="37px"> </Button> </LinearLayout> And My Java file is package com.tli.roadtripbingo; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.View.OnClickListener; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; public class WebView1 extends Activity { private Button Back; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.webview); Back = (Button)findViewById(R.id.back); WebView webView = (WebView) findViewById(R.id.webbrowser); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl("http://www.vikingredning.no/skilt.aspx"); webView.setWebViewClient(new HelloWebViewClient()); } class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }; } Thanks in advance Regards Tushar
-
Answer:
You can find answer here http://stackoverflow.com/questions/3389446/android-webview-changing-backcolor-and-font-color WebView myWebView = (WebView) findViewById(R.id.myWebView); myWebView.setBackgroundColor(Color.parseColor("#123456"));
iPhoneDeveloper at Stack Overflow Visit the source
Other answers
You may also want to reload the page after changing colors by using the reload() method: webView.reload();
Whatzit Toya
Related Q & A:
- How to stop a webview Android?Best solution by Stack Overflow
- How to change options menu background color in Android?Best solution by Stack Overflow
- How do I display limited html content in a webview?Best solution by Stack Overflow
- How can I call Android JavaScript functions in WebView?Best solution by Stack Overflow
- How to get html content from a webview?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.