Co pracował dla mnie było to: Czytałem, że w celu dopasowania do szerokości ekranu należy dodać do kodu HTML lub XML wewnątrz pola:
width="100%"
Więc co zrobiłem było, zamiast skalowania i powiększania obrazów, dostałem xml, umieściłem go w StringBuilderze, znalazłem src = "https://blablabla.com/image.png”, który jest w środku pola i tuż przed«src»podciąg włożeniu«width =»100%«», następnie y Ustaw moją Webview z StringBuilder, kod mi to:
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);
}
Nadzieja ta Pomaga, zajęło mi to kilka godzin, aby dowiedzieć się, jak rozwiązać ten problem:
Mam do czynienia z tym samym problemem, czy to już rozwiązałeś? – JochenJung
Przykro mi, ale jeszcze go nie rozwiązałem. "Mają rozwiązanie tutaj: http://developer.android.com/guide/webapps/targeting.html. Jak mówią, dodałem tag" width = device-width "w moim kodzie HTML, ale to nie działa: (Nadal szukam rozwiązania – Trox
Proszę o mnie. Czy rozwiązałeś to do teraz? – Yeung