M4t*_*euz 5 java android android-studio android-styles
我的Splash活动不会更改,只有在我将名称更改为另一个时,它才会更改。
例如:“ SplashActivity ”-从修改开始
如果将主题更改为另一种颜色,则需要将活动重命名为:“ SplashActivityy ”或其他名称。
如果我回到名称“ SplashActivity ”,则修改可以追溯到以后。
已经格式化并清除了android studio的缓存,这没有帮助!
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.cobaiascreen">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".App"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
SplashActivity.java
package com.example.cobaiascreen;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Hiding Title bar of this activity screen */
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
//Making this activity, full screen */
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
Run Code Online (Sandbox Code Playgroud)
App.java
package com.example.cobaiascreen;
import android.app.Application;
import android.os.SystemClock;
import java.util.concurrent.TimeUnit;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
// Don't do this! This is just so cold launches take some time
SystemClock.sleep(TimeUnit.SECONDS.toMillis(3));
}
}
Run Code Online (Sandbox Code Playgroud)
Styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
background_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/colorPrimaryDark"/>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/icon"/>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
编辑:问题就像我的一样: 飞溅主题不再改变
编辑2: 经过一段时间的烦躁,我没有发现与互联网相关的散步,我在一个线程中问了一个问题,以了解代码中发生了什么。
已经尝试清除缓存,重新创建应用程序,清除文件缓存,已经在android studio中进行了所有操作。
一段时间后,我发现正在谈论重新启动应用程序的事情似乎有所变化。
但是我不希望用户安装我的应用程序而必须重新启动应用程序以显示主题更改。我怎么解决这个问题?
当我深入分析代码时,我没有发现代码中出现“您在说什么”的原因。所以根据我的原因可能是您有多个drawable文件夹和文件
background_splash.xml
存在于所有文件夹中,或者至少存在于您的设备特定文件夹中,以及您要更改的其他文件夹中。
您正在更改的文件可能已插入,drawable-mdpi并且您的手机正在使用drawable-xxhdpi资源文件夹。
因此,请进行验证。样式也相同(如果适用)。
您可以采取的其他措施是
delete data,请
卸载该应用clear cache程序,然后重新安装。希望以上任何一种技术都能为您服务。
| 归档时间: |
|
| 查看次数: |
296 次 |
| 最近记录: |