我正在编写一个需要文本调整的Android应用程序,这本身不支持,我不认为使用WebView会因为与屏幕分辨率和尺寸相关的字体和文本大小而起作用.考虑到这一点,我将编写一个自定义视图,扩展TextView,它将进行文本调整,并想知道是否有人知道我可以看到的任何代码,这已经为我节省了一些时间.任何其他有用的建议也将非常感谢.
嗨,我有一个webview,我希望它适合屏幕,这样用户不必水平或垂直滚动
我之前搜索过,很多人建议如下,但它只限制宽度,用户仍然需要垂直滚动:
engine = (WebView) (findViewById(R.id.webView1));
engine.loadUrl(www.example.com);
engine.getSettings().setLoadWithOverviewMode(true);
engine.getSettings().setUseWideViewPort(true);
Run Code Online (Sandbox Code Playgroud)
我尝试了另一种方法,使用缩放方法,但它不会工作.....我得到窗口宽度(1024像素),网页内容宽度也是1024像素!因此缩放不起作用....有没有任何方法来获得正确的比例?
或....还有其他方式吗?....谢谢!!
// get the window width and height
Point outSize = new Point();
getWindowManager().getDefaultDisplay().getSize(outSize);
width = outSize.x;
height = outSize.y;
Log.i("Menuboard", "width: " + Integer.toString(width) + ", height: "
+ Integer.toString(height));
WebViewClient client = new WebViewClient() {
public void onPageFinished(WebView view, String url) {
int x = engine.getWidth();
int y = engine.getHeight();
Log.i("Menuboard", "web width: " + Integer.toString(x)
+ ", height: " + Integer.toString(y));
int scale1 = width * 100/x; …Run Code Online (Sandbox Code Playgroud)