webview fix

This commit is contained in:
cimenmus
2018-07-05 00:08:06 +03:00
parent dde2ff77ff
commit 90486130ee
2 changed files with 39 additions and 4 deletions

View File

@@ -85,9 +85,38 @@ public class StoreInfoFragment extends BaseFragment {
private void initWebView(StoreInfoModel storeInfoModel) {
storeInfoModel.checkNull();
setPizzalinkToolbarFields(false, storeInfoModel.getTitle());
storeInfoWebView.setVerticalScrollBarEnabled(false);
storeInfoWebView.getSettings().setJavaScriptEnabled(true);
storeInfoWebView.loadDataWithBaseURL("", storeInfoModel.getContent(), "text/html", "UTF-8", "");
storeInfoWebView.loadDataWithBaseURL("", createFixedHTML(storeInfoModel.getContent()), "text/html", "UTF-8", "");
}
private String createFixedHTML(String html){
String header = "<head><style>img{display: inline; height: auto; max-width: 100%;} html, body { width:100%; height: 100%; margin: 0px; padding: 0px;" + " }</style></head>";
//html = removeHs(html);
/*
String header = "<head>" +
" <meta http-equiv='content-type' content='text/html;'" +
" charset='UTF-8'>" +
" <style type='text/css'>" +
" " +
" @font-face {" +
" font-family: 'myfont';" +
" src: url('file:///android_asset/Resources/fonts/dosismedium.ttf');format('truetype'); " +
" }" +
" body { font-family:'myfont'; font-size: medium;}" +
" " +
" img{display: inline; height: auto; max-width: 100%;}" +
" </style>" +
" </head>";
*/
return "<html>" + header + "<body>" + html + "</body></html>";
}
}

View File

@@ -18,11 +18,17 @@
app:cardCornerRadius="4dp"
android:layout_margin="12dp">
<WebView
android:id="@+id/storeInfoWebView"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="12dp"/>
android:padding="8dp">
<WebView
android:id="@+id/storeInfoWebView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</android.support.v7.widget.CardView>