You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// PhoneWindowManager.javapublicStartingSurfaceaddSplashScreen(IBinderappToken, StringpackageName, inttheme,
CompatibilityInfocompatInfo, CharSequencenonLocalizedLabel, intlabelRes, inticon,
intlogo, intwindowFlags, ConfigurationoverrideConfig, intdisplayId) {
// 省略。。。Contextcontext = mContext;
if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen " + packageName
+ ": nonLocalizedLabel=" + nonLocalizedLabel + " theme="
+ Integer.toHexString(theme));
// Obtain proper context to launch on the right display.finalContextdisplayContext = getDisplayContext(context, displayId);
if (displayContext == null) {
// Can't show splash screen on requested display, so skip showing at all.returnnull;
}
context = displayContext;
if (theme != context.getThemeResId() || labelRes != 0) {
try {
context = context.createPackageContext(packageName, CONTEXT_RESTRICTED);
context.setTheme(theme);
} catch (PackageManager.NameNotFoundExceptione) {
// Ignore
}
}
if (overrideConfig != null && !overrideConfig.equals(EMPTY)) {
if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen: creating context based"
+ " on overrideConfig" + overrideConfig + " for splash screen");
finalContextoverrideContext = context.createConfigurationContext(overrideConfig);
overrideContext.setTheme(theme);
finalTypedArraytypedArray = overrideContext.obtainStyledAttributes(
com.android.internal.R.styleable.Window);
finalintresId = typedArray.getResourceId(R.styleable.Window_windowBackground, 0);
if (resId != 0 && overrideContext.getDrawable(resId) != null) {
// We want to use the windowBackground for the override context if it is// available, otherwise we use the default one to make sure a themed starting// window is displayed for the app.if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "addSplashScreen: apply overrideConfig"
+ overrideConfig + " to starting window resId=" + resId);
context = overrideContext;
}
typedArray.recycle();
}
finalPhoneWindowwin = newPhoneWindow(context);
win.setIsStartingWindow(true);
CharSequencelabel = context.getResources().getText(labelRes, null);
// Only change the accessibility title if the label is localizedif (label != null) {
win.setTitle(label, true);
} else {
win.setTitle(nonLocalizedLabel, false);
}
win.setType(
WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
// Assumes it's safe to show starting windows of launched apps while// the keyguard is being hidden. This is okay because starting windows never show// secret information.if (mKeyguardOccluded) {
windowFlags |= FLAG_SHOW_WHEN_LOCKED;
}
}
// Force the window flags: this is a fake window, so it is not really// touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM// flag because we do know that the next window will take input// focus, so we want to get the IME window up on top of us right away.win.setFlags(
windowFlags|
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
windowFlags|
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
win.setDefaultIcon(icon);
win.setDefaultLogo(logo);
win.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT);
finalWindowManager.LayoutParamsparams = win.getAttributes();
params.token = appToken;
params.packageName = packageName;
params.windowAnimations = win.getWindowStyle().getResourceId(
com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
params.privateFlags |=
WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED;
params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
if (!compatInfo.supportsScreen()) {
params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW;
}
params.setTitle("Splash Screen " + packageName);
addSplashscreenContent(win, context);
wm = (WindowManager) context.getSystemService(WINDOW_SERVICE);
view = win.getDecorView();
if (DEBUG_SPLASH_SCREEN) Slog.d(TAG, "Adding splash screen window for "
+ packageName + " / " + appToken + ": " + (view.getParent() != null ? view : null));
wm.addView(view, params);
// 省略。。。
}
//AndroidManifest
<activityandroid:name=".MainActivity"android:theme="@style/AppTheme">
<intent-filter>
<actionandroid:name="android.intent.action.MAIN" />
<categoryandroid:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
// MainTheme
<layer-listxmlns:android="http://schemas.android.com/apk/res/android">
<itemandroid:drawable="@android:color/white"/>
<itemandroid:top="100dp">
<bitmapandroid:gravity="top|center_horizontal"android:src="@drawable/logo"/>
</item>
<itemandroid:bottom="50dp">
<bitmapandroid:gravity="bottom|center_horizontal"android:src="@drawable/slogan"/>
</item>
</layer-list>
Others:
The text was updated successfully, but these errors were encountered:
Environment
问题描述
启动页在AndroidManifest中设置了自定义的theme,大致就是logo+slogan这样的背景,用来优化启动的用户体验的,现在发现背景中的图片都不会自动适配。
原因分析
startActivity时在Activity的第一帧渲染之前,系统会自动添加一个startingWindow,这个window创建时会应用配置的theme,但是应用启动时使用的相关context关联的DisplayMetric没有进行适配,导致这个现象。
解决方案
目前没有想到很好的解决方案 - -!特来求助
Related Code:
Others:
The text was updated successfully, but these errors were encountered: