【问题标题】:Splash screen attempt just shows a black screen启动画面尝试仅显示黑屏
【发布时间】:2019-02-03 10:29:13
【问题描述】:

我尝试在我的应用程序中实现启动画面,但它只是在我告诉他的时间内显示黑屏..

清单:

<activity android:name=".SplashScreen"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>

Java:

public class SplashScreen extends FragmentActivity {

    private static int SPLASH_TIME_OUT = 3000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_screen);

        new Handler().postDelayed(new Runnable(){
            @Override
            public void run(){
                Intent i = new Intent(SplashScreen.this,RSR_Revalidatieservice.class);
                startActivity(i);
                finish();
            }
        },SPLASH_TIME_OUT);

    }
}

XML:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SplashScreen">

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="32dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:srcCompat="@drawable/splash_logo_rsr" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/splash_logo" />
</android.support.constraint.ConstraintLayout>

我只是想显示大约 3 秒的初始屏幕,所以不需要在后台“加载”应用程序左右,我只想要一个很酷的启动器效果。

【问题讨论】:

    标签: android splash-screen


    【解决方案1】:

    替换: android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 来自您的清单 与:

    android:theme="@style/AppTheme.NoActionBar"
    

    【讨论】:

    • Apptheme 无法解析为符号...尝试使用 @android:style/Theme.Holo.NoActionBar 但它不起作用!
    • 使用主题代替apptheme
    • 现在它向我展示了一个没有两个图像视图的白屏......仍然是一个进步
    • @PhilémonRoubaud 而不是 src compat set src
    猜你喜欢
    • 2021-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    相关资源
    最近更新 更多