То, что работало для меня: я читал, что для того, чтобы соответствовать ширине экрана, вы должны добавить это в ваш HTML или XML внутри поля:
width="100%"
Так что я сделал, вместо масштабирования и масштабирования изображений я получил xml, поместил его в StringBuilder, нашел src = "https://blablabla.com/image.png", который находится внутри поля и непосредственно перед подстрокой «src» я вставил «width =« 100% »», тогда y установил мой webView с помощью StringBuilder, код mi:
public void setWebViewWithImageFit(String content){
// content is the content of the HTML or XML.
String stringToAdd = "width=\"100%\" ";
// Create a StringBuilder to insert string in the middle of content.
StringBuilder sb = new StringBuilder(content);
int i = 0;
int cont = 0;
// Check for the "src" substring, if it exists, take the index where
// it appears and insert the stringToAdd there, then increment a counter
// because the string gets altered and you should sum the length of the inserted substring
while(i != -1){
i = content.indexOf("src", i + 1);
if(i != -1) sb.insert(i + (cont * stringToAdd.length()), stringToAdd);
++cont;
}
// Set the webView with the StringBuilder: sb.toString()
WebView detailWebView = (WebView) findViewById(R.id.web_view);
detailWebView.loadDataWithBaseURL(null, sb.toString(), "text/html", "utf-8", null);
}
Надеюсь, что это поможет, мне потребовалось несколько часов, чтобы выяснить, как это решить.
его лучше не использовать LayoutAlgortihm.SINGLE_COLUMN как он устарел, является устаревшим. –