Search code examples
androidwebviewandroid-animationlayout-animation

Slide in Animation on webview data


I am showing a description like data which I am showing in webview & when uesr click on next I am changing webview data now I want to show some kind of slide in animation while changing webview's data can anyone suggest me how I can set animation to a single webview??

Thank You


Solution

  • I used this post to have the webpage slide in and out. The code is used for a custom webview client.

     private class HelloWebViewClient extends WebViewClient {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.setVisibility(View.GONE);
                mProgressDialog.setTitle("Loading");
                mProgressDialog.show();
                mProgressDialog.setMessage("Loading " + url);
                return false;
            }
    
            @Override
            public void onPageFinished(WebView view, String url) {
                mProgressDialog.dismiss();
                animate(view);
                view.setVisibility(View.VISIBLE);
                super.onPageFinished(view, url);
            }
        }
    
        private void animate(final WebView view) {
            Animation anim = AnimationUtils.loadAnimation(getBaseContext(),
                    android.R.anim.slide_in_left);
            view.startAnimation(anim);
        }