Android: How to create the Google Plus login anima

2019-07-24 17:42发布

Does anyone know how to create a similar animation to the login animation used in the Google Plus Android app?

Is there something similar in the Android SDK that I can use? Or should I just build it from scratch? I'm interested especially in the fact that the UI behind the modal animation is dimmed and disabled.

Thank you.

enter image description here

2条回答
Explosion°爆炸
2楼-- · 2019-07-24 17:54

Are you taking about that progress dialog spinning thingy that says "signing in"? That's not a custom animation at all, it's a common widget.

Here's the code:

        ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("Signing in...");
        progressDialog.show();
        //... complete sign in...then
        progressDialog.dismiss();

A ProgressDialog done this way, automatically takes care of dimming/blurring the background. You should really read about dialogs: http://developer.android.com/guide/topics/ui/dialogs.html

查看更多
Lonely孤独者°
3楼-- · 2019-07-24 18:03

To show the progression with an animated progress bar:

1- Initialize the ProgressDialog with the class constructor, ProgressDialog(Context). Set the progress style to "STYLE_HORIZONTAL" with setProgressStyle(int) and set any other properties, such as the message.

2- When you're ready to show the dialog, call show() or return the ProgressDialog from the onCreateDialog(int) callback.

3- You can increment the amount of progress displayed in the bar by calling either setProgress(int) with a value for the total percentage completed so far or incrementProgressBy(int) with an incremental value to add to the total percentage completed so far.

For example, your setup might look like this:

ProgressDialog progressDialog;
progressDialog = new ProgressDialog(mContext);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);

The setup is simple. Most of the code needed to create a progress dialog is actually involved in the process that updates it. You might find that it's necessary to create a second thread in your application for this work and then report the progress back to the Activity's UI thread with a Handler object. If you're not familiar with using additional threads with a Handler, see the example Activity below that uses a second thread to increment a progress dialog managed by the Activity.

查看更多
登录 后发表回答