2

How do I get rid of the blank page usually with the app name as a title that loads when you start up your application. I've done some reasearch and the best explanation/solution I found was to set the application's theme to null so the android system doesn't draw that page.

I have tried this but it doesn't work though in principle I think it should.

In my styles.xml I have

<style name="NoBackground" parent="android:Theme">
    <item name="android:windowBackground">@null</item>
</style>

and in my manifest file I have

<application
    android:name=".FIXR"
    android:allowBackup="true"
    android:icon="@drawable/launcher"
    android:label="@string/app_name"
    android:theme="@style/NoBackground" >

Is there a better way to get rid of this?

4

5 回答 5

1

如果您的应用程序具有服务或您在方法上运行异步任务onCreate,则显示带有进程对话框的初始屏幕,并在加载所有源后切换到主屏幕。这是一种技术。

为了让您轻松工作,我切断了部分代码:

启动器.xml

实际上它是您的启动画面:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:src="@drawable/splashscreen" 
    android:scaleType="fitXY" />

<ProgressBar 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content"
    android:layout_gravity="center_horizontal|bottom" />

在您的主要活动中:

 setContentView(R.layout.launcher);

 mHandler = new Handler();

 //if Service is Ready: ....

 mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent().setClass(LaunchActivity.this, OtherActivity.class).setData(getIntent().getData()));
                finish();
            }
        }, 1000);

希望它可以帮助您解决问题

于 2013-08-16T09:01:23.817 回答
1

我用这个,它对我有用

<application
    android:name="com.example.G"
    android:icon="@drawable/ic_app"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar"
    >
于 2013-08-16T09:22:42.623 回答
0

我认为它的显示是因为您的应用程序的第一页需要时间来加载。您可能在 onCreate() 活动方法上做了太多工作。所以我建议在活动开始时尽量减少负载。这样就不会出现黑屏。

希望你能理解!!

于 2013-08-16T08:59:14.353 回答
0

style.xml创建中:

<style name="SplashPage">
    <item name="android:windowBackground">@color/white</item>
</style>

然后在AndroidManifest.xml您的启动器活动中,指定活动主题:

<activity
    android:name=".activity.MainActivity"
    android:label="@string/title_activity_main"
    android:theme="@style/SplashPage"
    android:screenOrientation="portrait" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
于 2015-01-05T09:13:06.450 回答
0

试试下面的代码行,在你的 res/values/styles.xml 中添加这些行:

--------

<style name="SplashScreen">
    <item name="android:padding">0dp</item>
    <item name="android:windowBackground">@android:color/black</item>
    <item name="android:windowFrame">@null</item>
</style>

在您的清单文件中,只需将其作为样式在您的活动标签下传递为:

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
    android:name="com.mpg.myapp.MainActivity"
    android:theme="@style/SplashScreen"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

可能这会对你有所帮助。

于 2015-10-27T09:44:28.377 回答