I have an app built using Android Studio. The application simply displays HTML pages from the assets folder. These HTML pages were written by Microsoft Office FrontPage.
In Android I have a simple webview that is:
public class Web_Activity extends AppCompatActivity {;
int pageNum;
WebView webView;
String Title;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
WebView webView = (WebView) findViewById(R.id.webView);
WebView webView1 = (WebView)findViewById(R.id.webView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
webView.getSettings().setDisplayZoomControls(false);
}
webView.getSettings().setBuiltInZoomControls(true);
Intent intent = getIntent();
String link = intent.getStringExtra("link");
webView.loadUrl("file:///android_asset/"+link);
}
}
This is the page template:
<html dir="rtl">
<head>
<meta http-equiv="content-type" content="text/html;" charset="windows-1256">
<style>
/** Specify a font named "Arial",
and specify the URL where it can be found: */
@font-face {
font-family: "Arial";
src: url('file:///android_asset/font/font.otf');
}
h3 { font-family:"Arial"}
</style>
</head>
<body background="ricebk.jpg">
<p><font face="Arial"><span style="font-size: 17pt">
Hi! Here texts are displayed, formatted, etc.
</span></font></p>
What I need is to add an in-app button within WebView that changes the background of the HTML page.
This:
<body background="ricebk.jpg">
Change it, for example, to:
<body background="ricebk2.jpg">
I want to put a white background and a black one and change as desired. I've spent hours searching for a way within the Q&A and my head is spinning, and I can't find a solution to it.