[英]How to make an activity blur then disappear with new activity?
我有一個slpash屏幕,其中有一個圖像,我想在調用下一個活動之前使圖像或活動模糊。
我嘗試使用fade_in fade_out動畫,但無法正常工作。
嘗試過的代碼在此可接受的答案中給出: Android Studio逐漸淡入主屏幕
閃屏
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;
}
}
淡入 :
<?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" />
淡出 :
<?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" />
對於模糊動畫我該怎么辦? 我希望slpash活動在另一個活動開始之前看起來模糊。
請幫助。謝謝。
如果overridePendingTransition無法按您想要的fade_in和fade_out工作。 您可以采取解決方法。 導航之前,請使用以下動畫庫將您的應用容器的動畫制作為“模糊”: https : //github.com/2359media/EasyAndroidAnimations或https://github.com/daimajia/AndroidViewAnimations,然后使用動畫淡入內容下一個活動,並使用activity.overridePendingTransition(NO_ANIMATION,NO_ANIMATION);
注意:這不是我嘗試過的方法,但是應該可以
您可以如下所示在splash_layout中添加一個疊加層,以產生暗淡的效果。 並在開始新活動之前使其可見。
<View
android:id="@+id/overlay_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A0000000"
android:visibility="gone" />
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.