Ce qui a fonctionné pour moi était le suivant: je lis que pour la largeur de l'écran, vous devez ajouter à votre HTML ou XML dans le champ: au lieu
width="100%"
Alors ce que je faisais était, de mise à l'échelle et de zoom sur les images, j'ai obtenu le xml, le mettre dans un StringBuilder, a trouvé le src = "https://blablabla.com/image..png » qui est à l'intérieur du terrain et juste avant le "" sous-chaîne I inséré le "src width =" 100% "", puis y tournai ma webView avec le StringBuilder, le code mi est la suivante:
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);
}
Hope this aide, il m'a fallu quelques heures pour trouver comment résoudre ce problème
Je suis confronté au même problème, l'avez-vous résolu? – JochenJung
Je suis désolé mais je ne l'ai toujours pas résolu. Comme on dit, j'ai ajouté la balise "width = device-width" dans mon code HTML, mais cela ne fonctionne pas: http://developer.android.com/guide/webapps/targeting.html (Je cherche encore une solution – Trox
Excusez-moi, avez-vous résolu cela jusqu'à maintenant? – Yeung