set LayoutAlgorithm.SINGLE_COLUMN in webviews to fit images without css

hacks
This commit is contained in:
Andrew Dolgov 2012-06-26 21:45:35 +04:00
parent 0702083fb2
commit b80b684d12
2 changed files with 8 additions and 6 deletions

View File

@ -31,6 +31,7 @@ import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
@ -109,6 +110,8 @@ public class ArticleFragment extends Fragment {
ws.setSupportZoom(true); ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true); ws.setBuiltInZoomControls(true);
web.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
TypedValue tv = new TypedValue(); TypedValue tv = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true); getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true);
@ -160,12 +163,10 @@ public class ArticleFragment extends Fragment {
"<html>" + "<html>" +
"<head>" + "<head>" +
"<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" + "<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" +
//"<meta name=\"viewport\" content=\"target-densitydpi=device-dpi\" />" +
"<style type=\"text/css\">" + "<style type=\"text/css\">" +
"body { padding : 0px; margin : 0px; }" + "body { padding : 0px; margin : 0px; }" +
cssOverride + cssOverride +
"div.attachments { font-size : 70%; margin-top : 1em; }" + /* "img { max-width : 98%; height : auto; }" + */
"img { max-width : 98%; height : auto; }" +
"</style>" + "</style>" +
"</head>" + "</head>" +
"<body>" + articleContent; "<body>" + articleContent;

View File

@ -27,6 +27,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.widget.TextView; import android.widget.TextView;
public class OfflineArticleFragment extends Fragment { public class OfflineArticleFragment extends Fragment {
@ -102,6 +103,8 @@ public class OfflineArticleFragment extends Fragment {
ws.setSupportZoom(true); ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true); ws.setBuiltInZoomControls(true);
web.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
TypedValue tv = new TypedValue(); TypedValue tv = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true); getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true);
@ -167,11 +170,9 @@ public class OfflineArticleFragment extends Fragment {
"<html>" + "<html>" +
"<head>" + "<head>" +
"<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" + "<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" +
//"<meta name=\"viewport\" content=\"target-densitydpi=device-dpi\" />" +
"<style type=\"text/css\">" + "<style type=\"text/css\">" +
"body { padding : 0px; margin : 0px; }" + "body { padding : 0px; margin : 0px; }" +
cssOverride + cssOverride +
"img { max-width : 98%; height : auto; }" +
"</style>" + "</style>" +
"</head>" + "</head>" +
"<body>" + articleContent + "</body></html>"; "<body>" + articleContent + "</body></html>";