独自のアプリを作成するためのこれまでになく厳しい努力の中で、私はさらに別のレンガの壁にぶつかりました。
詳細
私は今日、WebView
ズームコントロールが組み込まれているので、そこから移行することにしましたImageView
...私の問題は、API 3を実行しているアクティブなユーザーがまだいるということです...更新を書くときは、そのことを覚えておく必要がありますこのアプリ
私は何をしようとしていますか?
サーバーから画像をロードWebView
し、画面によってサイズが異なるウィンドウに合わせて表示するだけです。
何を試しましたか
#1を試してください(私の個人的な試み)
//iW & iH are the height and width of the image passed from the server
//Calc the scale needed to fit width
int scW = (int) ((iW / (float)wView.getMeasuredHeight()) * 100);
//Calc the scale needed to fit height
int scH = (int) ((iH / (float)wView.getMeasuredHeight()) * 100);
//fit the bigger of the 2
if (scW < scH)
{
wView.setInitialScale(scW);
}
else
{
wView.setInitialScale(scH);
}
String pUrl = "http://app.guycothal.com/Funnys/2012724133312929.png";
wView.loadUrl(pUrl);
これにより、すべての写真に多くの空きスペースがある写真が残ります
#2を試してください(StackOverFlowで見つかりました)
String pUrl = "http://app.guycothal.com/Funnys/2012724133312929.png";
String html="<html><body><img src=\"" + pUrl +
"\" width=\"10%37\" height=\"10%37\"/></body></html>";
wView.loadData(html, "text/html", "utf-8");
これにより、画像が巨大になります...つまり、巨大です
#3を試してください(StackOverFlowで見つかりました)
wView.setWebViewClient(null);
wView.getSettings().setJavaScriptEnabled(true);
wView.getSettings().setLoadWithOverviewMode(true);//NEeds api 7
wView.getSettings().setUseWideViewPort(true);
wView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
wView.getSettings().setBuiltInZoomControls(true);
wView.getSettings().setSupportZoom(true);
wView.getSettings().setUseWideViewPort(true);
wView.setScrollbarFadingEnabled(false);//Needs api 5
String pUrl = "http://app.guycothal.com/Funnys/2012724133312929.png";
wView.loadUrl(pUrl);
必要なAPIと3つ以上のAPI以外...それらの行がなくても、画像が再び巨大になります
#4を試してください(ここでも見つかりました!!! <---少なくとも最初に検索します)
wView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
String pUrl = "http://app.guycothal.com/Funnys/2012724133312929.png";
wView.loadUrl(pUrl);
Froyo (API 7) 以降が必要
_ #5 を試す (考えすぎてこの質問を書きながら試しました)
//iW & iH are the height and width of the image passed from the server
int iMW = imgView.getMeasuredWidth();
int iMH = imgView.getMeasuredHeight();
int scW = (int) ((iW / (float)iMW) * 100);
int scH = (int) ((iH / (float)iMH) * 100);
if (iMW < iW && iMH < iH)
{
if (scW < scH)
{
wView.setInitialScale(scW);
}
else
{
wView.setInitialScale(scH);
}
}
if (iMW < iW && iMH > iH)
{
wView.setInitialScale(scH);
}
if (iMW > iW && iMH < iH)
{
wView.setInitialScale(scW);
}
if (iMW < iW && iMH < iH)
{
if (scW > scH)
{
wView.setInitialScale(scW);
}
else
{
wView.setInitialScale(scH);
}
}
wView.loadUrl(pUrl);
次は何ですか?
ここからどこへ行けばいいのかわからない...この1つの簡単なことで一日中自殺してきた...髪を抜く前に助けてください
ps私はハゲです...だから、これは冗談です