[英]How to make an activity blur then disappear with new activity?
I have a slpash screen which has one image I want to make the image or activity blur before the next activity gets called. 我有一个slpash屏幕,其中有一个图像,我想在调用下一个活动之前使图像或活动模糊。
I tried to use fade_in fade_out anim but its not working. 我尝试使用fade_in fade_out动画,但无法正常工作。
Tried code given in this accepted answer : Android Studio fading splash into main 尝试过的代码在此可接受的答案中给出: Android Studio逐渐淡入主屏幕
splashScreen 闪屏
public class SplashScreen extends Activity {
private Thread mSplashThread;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_layout);
final SplashScreen sPlashScreen = this;
mSplashThread = new Thread(){
@Override
public void run(){
try {
synchronized(this){
wait(3000);
}
}
catch(InterruptedException ex){
}
finish();
Intent intent = new Intent();
intent.setClass(sPlashScreen,LoginActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
};
mSplashThread.start();
}
@Override
public boolean onTouchEvent(MotionEvent evt)
{
if(evt.getAction() == MotionEvent.ACTION_DOWN)
{
synchronized(mSplashThread){
mSplashThread.notifyAll();
}
}
return true;
}
}
Fade_in : 淡入 :
<?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" />
Fade_out : 淡出 :
<?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" />
What Can I do for blur animation? 对于模糊动画我该怎么办? I want the slpash activity to look blur before the another activity starts. 我希望slpash活动在另一个活动开始之前看起来模糊。
Please help.Thank you.. 请帮助。谢谢。
If overridePendingTransition doesn't work as you want for fade_in and fade_out. 如果overridePendingTransition无法按您想要的fade_in和fade_out工作。 You can make a workaround. 您可以采取解决方法。 before navigating, make a animation for your app container to Blur, using a animation library like: https://github.com/2359media/EasyAndroidAnimations or https://github.com/daimajia/AndroidViewAnimations And an animation to fade in the content of the next activty, and use activity.overridePendingTransition(NO_ANIMATION, NO_ANIMATION); 导航之前,请使用以下动画库将您的应用容器的动画制作为“模糊”: https : //github.com/2359media/EasyAndroidAnimations或https://github.com/daimajia/AndroidViewAnimations,然后使用动画淡入内容下一个活动,并使用activity.overridePendingTransition(NO_ANIMATION,NO_ANIMATION);
Note: this is not something I tried, but it should work 注意:这不是我尝试过的方法,但是应该可以
You can add one overlay in splash_layout as shown below to have the dim effect. 您可以如下所示在splash_layout中添加一个叠加层,以产生暗淡的效果。 and make it visible before starting the new activity. 并在开始新活动之前使其可见。
<View
android:id="@+id/overlay_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A0000000"
android:visibility="gone" />
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.