Screen flickers after Google Sign In dialog dismiss android studio

依然范特西╮ 提交于 2020-08-02 05:27:09

问题


I'm facing this issue and am not able to find a solution to it. I have Google Sign In implemented in my app using firebase. The problem I'm facing is that whenever the Sign In dialog dismisses a black strip runs across the screen from top to bottom. It moves very fast but still is noticeable. I want to remove this black strip that runs across the screen so the user smoothly returns to the screen.

I tried to add

overridePendingTransition(0, 0);

in onPause() and onResume() methods but still found no success.

Could anybody please help me to find a way around this and/or how could I achieve it?


回答1:


I had the same problem and it bothered me, it didn't look good.

I found a solution! You can define activity open and close animations in styles.xml and assign them to the activity which starts the google sign in by using android:windowAnimationStyle. Here is an example using fade animations:

styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowAnimationStyle">@style/ActivityAnimations</item>
</style>

<style name="ActivityAnimations" parent="@android:style/Animation.Activity">
    <item name="android:activityOpenEnterAnimation">@anim/fade_in</item>
    <item name="android:activityOpenExitAnimation">@anim/fade_out</item>
    <item name="android:activityCloseEnterAnimation">@anim/fade_in</item>
    <item name="android:activityCloseExitAnimation">@anim/fade_out</item>
</style>

The style AppTheme is assigned to the application or the activity that launches the google sign in flow in the AndroidManifest.xml using android:theme="@style/AppTheme".

FadeIn:

<?xml version="1.0" encoding="utf-8"?>
    <alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:fromAlpha="0.0" android:toAlpha="1.0"
    android:duration="500"
    />

FadeOut:

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:fromAlpha="1.0" android:toAlpha="0.0"
    android:fillAfter="true"
    android:duration="500"
    />


来源:https://stackoverflow.com/questions/56484002/screen-flickers-after-google-sign-in-dialog-dismiss-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!