Change font in webview code programmatically - android

I have a problem. I have to change the font in my webview. I mean I have a html page in assets and font of the html page is default font. I want to change font of the html page but it must be done in code in android application. This is possible?

Related

How can I change font style for part of a text in android webView

I want to add different String elements with different font styles to one webView in android. I have done the same thing using textView before, but I don't know how to do it with webView

How to set default typeface of Android WebView

How to set default typeface of a WebView in Android?
I know, I can use CSS fonts,
But how can I use it when I want to show an external URL like http://HossainCo.ir
For example, In dekstop firefox (currently I used) we can set default font to use when no other fonts used in CSS or HTML
So: I want to use "assets" font like "fonts/tohoma.ttf" when using webView.loadUrl("hossainco.ir");

How to get WebView to ignore css

I am trying to load a local HTML page in an Android Webview. This page contains some layouting using CSS. But I also noticed that the Webview has a setBackgroundColor() method in which you can set a background color. however this does not work when the CSS file also set a background color.
Does anyone know how to make the Android Webview to ignore these CSS style when I set my own background color?
What you could do is add style to your page with javascript:
webview.loadUrl("javascript:document.body.style.background = color;");
Call this after you have loaded your url or html.
PS I think if you ignored the CSS you would the get the default white background even if you set setBackGroundColor()
setBackGroundColor is a method that all Views have, that's the only reason WebView has it imo.

Is possible to render any page which user want but to load some local style like style='color:white;?

I have WebView control on my page and I need to change default font settings like color and font. Is possible to render any page which user want but to load some local style like style='color:white; ? Where to put css and how to load css ?

Android 2.3 Hebrew fonts in Webview

I am porting an app that displays Hebrew to Android 2.3. The 2.3 emulator displays the strings correctly when in a TextView, but when I try to put the strings in a WebView, the webview just displays gibberish.
This tells me that the Hebrew fonts are available in the emulator but the webview code has something missing.
This is the code:
WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.loadData("<html><body>"+temp1 +"</body></html>",
"text/html", "UTF-8");
Any ideas on how to get the emulator to display the webview correctly.
When you display the page, you aren't giving a way for the browser to know that your page uses a right-to-left script.
You can use the HTML dir attribute in a markup element that surrounds your right-to-left text (it should detect automatically which characters to reverse, and which not to). (For more details, look at this note from W3C - it seems to be implemented in Chrome at least.)
Probably the most expedient way would be to rewrite the first tag as:
<html dir="rtl">
I changed the font of the webview by adding
mWebView.getSettings().setFixedFontFamily("DroidSansHebrew.ttf");
The text is rendered in the correct font but left-to-right which is not the correct orientation for Hebrew.

Categories

Resources