我创建了一个在WebView上启动网站的Activity,我添加了一些缩放支持和缩放控件。我的问题:当我想从网站缩放左侧部分时,通过使用捏缩放或控制,总是显示右侧而不是左侧,当我想要左侧scrool时,webview是“被阻止”我的意思是它只显示右侧就是它。我希望你理解我! 这是我使用的代码:
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setSupportZoom(true);
mWebView.setInitialScale(65);
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
//Make the bar disappear after URL is loaded, and changes string to Loading...
MyActivity.setTitle("Loading...");
MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
// Return the app name after finish loading
if(progress == 100)
MyActivity.setTitle(R.string.app_name);
}
});
mWebView.setWebViewClient(new Manipulation());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("myURL");
请问如何解决缩放问题?
答案 0 :(得分:0)
public class WebViewHelp extends Activity {
//specify url to open
String url="";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri uri=Uri.parse(url);
Intent i=new Intent(Intent.ACTION_VIEW,uri);
startActivity(i);
}
}
答案 1 :(得分:0)
//xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
//Activity
public class Main extends Activity {
//specify the url to open
String url="";
private WebView myWebView;
private static final FrameLayout.LayoutParams ZOOM_PARAMS =
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.webview);
this.myWebView = (WebView) this.findViewById(R.id.webView);
FrameLayout mContentView = (FrameLayout) getWindow().
getDecorView().findViewById(android.R.id.content);
final View zoom = this.myWebView.getZoomControls();
mContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.GONE);
this.myWebView.loadUrl(url);
}
}