Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 逐帧动画启动屏幕_Java_Android_Animation_Automation_Splash Screen - Fatal编程技术网

Java 逐帧动画启动屏幕

Java 逐帧动画启动屏幕,java,android,animation,automation,splash-screen,Java,Android,Animation,Automation,Splash Screen,[Android Studio]我正在尝试让一些帧一个接一个地快速显示,然后在启动时自动切换到不同的活动 我可以让splash活动在继续之前等待适当的时间,但动画仍然无法播放 我正在使用此人的方法()制作帧的动画,并将其显示到ImageView中-在本例中,动画由一个停止和开始按钮控制,该按钮将帧设置为无休止地循环(或不循环),但我只希望在应用程序启动时将其激活并显示 我目前实现此方法的方式是,一旦读取特定行,应用程序就会崩溃,但我可能只是做错了,因此任何帮助都将受到感谢。谢谢。:) Andro

[Android Studio]我正在尝试让一些帧一个接一个地快速显示,然后在启动时自动切换到不同的活动

我可以让splash活动在继续之前等待适当的时间,但动画仍然无法播放

我正在使用此人的方法()制作帧的动画,并将其显示到ImageView中-在本例中,动画由一个停止和开始按钮控制,该按钮将帧设置为无休止地循环(或不循环),但我只希望在应用程序启动时将其激活并显示

我目前实现此方法的方式是,一旦读取特定行,应用程序就会崩溃,但我可能只是做错了,因此任何帮助都将受到感谢。谢谢。:)

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.company.framebyframe">

    <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">
        <activity android:name=".SplashActivity">
            <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.HOME" />

                <category android:name="android.intent.category.MAIN" />
            </intent-filter>
        </activity>
    </application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<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"
    android:id="@+id/splash_layout"
    android:background="@drawable/custom_animation">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center" />
    </FrameLayout>

</android.support.constraint.ConstraintLayout>
当我开始取消引用这些行时,往往会发生崩溃:

imageView = (ImageView) findViewById(R.id.imageView);

imageView.setBackgroundResource(R.drawable.custom_animation);

PS:如果有任何命名错误,可能是因为我试图使文件名更通用、更易懂,但请随意指出您认为可能会导致问题的任何内容。

您需要在活动类上设置布局,否则应用程序将不知道应该膨胀什么布局。这是您的应用程序在尝试查找图像视图时崩溃的主要原因,因为您尚未设置内容布局。在
super.onCreate
之后和尝试操作任何UI元素之前添加此行

setContentView(R.layout.activity_splash);
另外,删除约束布局上的背景声明,您已经将动画可绘制视图加载到图像视图中

<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"
    android:id="@+id/splash_layout">  

    ... 

</android.support.constraint.ConstraintLayout>

... 

您需要在activity类上设置布局,否则应用程序将不知道应该膨胀什么布局。这是您的应用程序在尝试查找图像视图时崩溃的主要原因,因为您尚未设置内容布局。在
super.onCreate
之后和尝试操作任何UI元素之前添加此行

setContentView(R.layout.activity_splash);
另外,删除约束布局上的背景声明,您已经将动画可绘制视图加载到图像视图中

<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"
    android:id="@+id/splash_layout">  

    ... 

</android.support.constraint.ConstraintLayout>

... 

知道这很简单。非常感谢你,我爱你。:)我知道这很简单。非常感谢你,我爱你。:)