如果有人能帮助我,我会很高兴。我有一个使用webview的应用程序。 webview加载一个网址,我已经使用Google教程覆盖了我想用webview打开的所有其他链接。我在res/
和slide_right xml
中创建了一个动画文件,效果非常好。我在我的主要java活动中调用了这个效果,但它仅适用于第一页。我想要的是在webview中链接加载的每个页面中应用的效果。如何在web视图中使用android过渡效果?
你能用我的代码来帮助我吗?
package com.ihome;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class IhomeActivity extends Activity {
WebView mWebView;
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Animation slideRightAnimation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.slide_right);
mWebView.startAnimation(slideRightAnimation);
view.loadUrl(url);
return true;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
Animation slideLeftAnimation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.slide_left);
mWebView.startAnimation(slideLeftAnimation);
mWebView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com/");
mWebView.setWebViewClient(new HelloWebViewClient());
你好,任何人都可以帮助我解决上述问题吗?我应该上传我的代码吗? – alexgeorg86
我上面贴出我的代码,请帮我... – alexgeorg86
希望这有助于 http://stackoverflow.com/q/7641121/577046 – Synxmax