mirror of
https://gitea.winboll.cc/ZhanGSKen/MyWinBoLL.git
synced 2026-08-14 05:27:10 +08:00
feat: 添加主界面开屏动画
MainActivity首次启动时显示5秒开屏画面,展示应用标题和副标题。 - 使用FrameLayout覆盖层实现居中展示 - 标题和副标题依次淡入,5秒后整体淡出 - 开屏背景使用主色调,文字白色/半透明白色 - onDestroy中清理Handler防止内存泄漏
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Fri Jul 10 13:02:55 HKT 2026
|
||||
#Fri Jul 10 20:15:30 CST 2026
|
||||
stageCount=4
|
||||
libraryProject=
|
||||
baseVersion=15.20
|
||||
publishVersion=15.20.3
|
||||
buildCount=0
|
||||
buildCount=3
|
||||
baseBetaVersion=15.20.4
|
||||
|
||||
@@ -2,8 +2,13 @@ package cc.winboll.studio.bytheway;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.bytheway.activities.AboutActivity;
|
||||
import cc.winboll.studio.bytheway.activities.BaseWinBoLLActivity;
|
||||
@@ -18,6 +23,11 @@ import cc.winboll.studio.libappbase.ToastUtils;
|
||||
public class MainActivity extends BaseWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
private static final long SPLASH_DURATION = 5000L;
|
||||
private static final long SPLASH_FADE_IN = 800L;
|
||||
private static final long SPLASH_FADE_OUT = 500L;
|
||||
private View splashOverlay;
|
||||
private final Handler splashHandler = new Handler();
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
@@ -33,6 +43,7 @@ public class MainActivity extends BaseWinBoLLActivity {
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
initSplash();
|
||||
ToastUtils.show("onCreate");
|
||||
}
|
||||
|
||||
@@ -41,6 +52,12 @@ public class MainActivity extends BaseWinBoLLActivity {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
splashHandler.removeCallbacksAndMessages(null);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
AESThemeUtil.inflateCompatThemeMenu(this, menu);
|
||||
@@ -76,4 +93,43 @@ public class MainActivity extends BaseWinBoLLActivity {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initSplash() {
|
||||
splashOverlay = findViewById(R.id.splash_overlay);
|
||||
final TextView splashTitle = findViewById(R.id.splash_title);
|
||||
final TextView splashSubtitle = findViewById(R.id.splash_subtitle);
|
||||
|
||||
AlphaAnimation fadeInTitle = new AlphaAnimation(0f, 1f);
|
||||
fadeInTitle.setDuration(SPLASH_FADE_IN);
|
||||
fadeInTitle.setFillAfter(true);
|
||||
splashTitle.startAnimation(fadeInTitle);
|
||||
|
||||
AlphaAnimation fadeInSubtitle = new AlphaAnimation(0f, 1f);
|
||||
fadeInSubtitle.setDuration(SPLASH_FADE_IN);
|
||||
fadeInSubtitle.setStartOffset(SPLASH_FADE_IN);
|
||||
fadeInSubtitle.setFillAfter(true);
|
||||
splashSubtitle.startAnimation(fadeInSubtitle);
|
||||
|
||||
splashHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AlphaAnimation fadeOut = new AlphaAnimation(1f, 0f);
|
||||
fadeOut.setDuration(SPLASH_FADE_OUT);
|
||||
fadeOut.setFillAfter(true);
|
||||
fadeOut.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
splashOverlay.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {}
|
||||
});
|
||||
splashOverlay.startAnimation(fadeOut);
|
||||
}
|
||||
}, SPLASH_DURATION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/toolbar"/>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center_vertical|center_horizontal">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/toolbar"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center_vertical|center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ByTheWay"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/splash_overlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/splashBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ByTheWay"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:padding="32dp">
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/splash_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/splash_title"
|
||||
android:textColor="@color/splashTitleText"
|
||||
android:textSize="36sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/splash_subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/splash_subtitle"
|
||||
android:textColor="@color/splashSubtitleText"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="italic"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
@@ -9,4 +9,7 @@
|
||||
<color name="toolbarBackgroundColor">#1565C0</color>
|
||||
<color name="debugTextColor">#616161</color>
|
||||
<color name="colorTextBackgound">#FAFAFA</color>
|
||||
<color name="splashBackground">#1565C0</color>
|
||||
<color name="splashTitleText">#FFFFFF</color>
|
||||
<color name="splashSubtitleText">#B3FFFFFF</color>
|
||||
</resources>
|
||||
@@ -4,5 +4,7 @@
|
||||
<string name="action_gps_list">GPS列表</string>
|
||||
<string name="action_about">应用介绍</string>
|
||||
<string name="app_description">The [ByTheWay] project is designed to quickly schedule task reminders related to time and location. Its main feature is the ability to quickly create task-related data.</string>
|
||||
|
||||
<string name="splash_title">ByTheWay</string>
|
||||
<string name="splash_subtitle">By the way, I mention this for you.</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user