I am using webview in android to display terms and conditions , but the issue is I need to make application supports for Arabic language. Here it required make the text direction Right to Left (RTL). But I followed lot ways to solve this. Can you please check the ways and suggest me once.
Process One
private String mUrl="terms_conditions_url";
WebView webview=findViewById(R.id.web_view);
if(ltrDirection){
/** For LTR text */
webView.loadData(mUrl);
}else{
/** For RTL text */
mWebView.loadDataWithBaseURL(mURL,"<html><body dir=\"rtl\"></body></html>", "text/html", "UTF-8", null);
}
Process Two
And also I followed another way it is like..,
private String mUrl="terms_conditions_url";
WebView webview=findViewById(R.id.web_view);
if(ltrDirection){
/** For LTR text */
webView.loadData(mUrl);
}else{
/** For RTL text */
mWebView.loadDataWithBaseURL(mURL,"<html dir=\"rtl\"></html>", "text/html", "UTF-8", null);
}
But nothing is worked for me.
Please give me the best code for it.
Use this code! updated!
WebView wv;
String outhtml = "Terms and Condition are as follows....your strings";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wv = (WebView) findViewById(R.id.web_test);
wv.loadDataWithBaseURL(mURL, "<html dir=\"rtl\" lang=\"\"><body>" + outhtml + "</body></html>", "text/html", "UTF-8", null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With