Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.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活动向后提示,否则无法工作_Java_Android_Android Animation - Fatal编程技术网

我的第一个Java活动中的动画不';除非通过第二个Java活动向后提示,否则无法工作

我的第一个Java活动中的动画不';除非通过第二个Java活动向后提示,否则无法工作,java,android,android-animation,Java,Android,Android Animation,我的第一个活动java文件源代码没有按我想要的方式工作。我似乎无法在第一次活动开始时运行动画。我只能在第二次Java活动之后通过在Android键盘上用力按返回到第一次活动来运行它 package com.demotxt.droidsrce.welcomescreen; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import

我的第一个活动java文件源代码没有按我想要的方式工作。我似乎无法在第一次活动开始时运行动画。我只能在第二次Java活动之后通过在Android键盘上用力按返回到第一次活动来运行它

package com.demotxt.droidsrce.welcomescreen;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;

public class WelcomeActivity extends AppCompatActivity {
    LinearLayout l1, l2;
    Button btnsub;
    Animation uptodown, downtoup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        btnsub = (Button) findViewById(R.id.buttonsub);
        btnsub.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NextActivity();
            }
        });
    }

    public void NextActivity() {
        Intent intent = new Intent(this, NextActivity.class);
        startActivity(intent);
        l1 = (LinearLayout) findViewById(R.id.l1);
        l2 = (LinearLayout) findViewById(R.id.l2);
        uptodown = AnimationUtils.loadAnimation(this, R.anim.uptodown);
        downtoup = AnimationUtils.loadAnimation(this, R.anim.downtoup);
        l1.setAnimation(uptodown);
        l2.setAnimation(downtoup);
    }
}
这是我的第一个活动的XML文件,这里的一切都运行顺利,但我也有同样的问题。前后运行java和XML脚本以同时运行动画似乎存在问题

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="com.demotxt.droidsrce.welcomescreen.WelcomeActivity"
    android:orientation="vertical"
    android:background="@drawable/background">

    <LinearLayout
        android:id="@+id/l1"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="25dp"
            android:text="Welcome to"
            android:textColor="@color/lightorange"
            android:textSize="30sp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="398dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="50dp"
            android:text="           BLUEY AUSTRALIA"
            android:textAlignment="textStart"
            android:textColor="@android:color/holo_blue_light"
            android:textColorHighlight="@android:color/holo_blue_bright"
            android:textColorHint="@android:color/holo_blue_bright"
            android:textColorLink="@android:color/holo_blue_bright"
            android:textSize="30sp" />

        <ImageView
            android:id="@+id/Bluey_logo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/bluey_logo" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="TextView" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/l2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:background="@drawable/spaceullustration"
        android:orientation="vertical">

        <Button

            android:id="@+id/buttonsub"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/buttonstyle"
            android:text="JOIN BLUEY"
            android:textColor="@color/bluey"
            android:textSize="30sp" />
    </LinearLayout>


</LinearLayout>

尝试更改订单

    l1 = (LinearLayout) findViewById(R.id.l1);
    l2 = (LinearLayout) findViewById(R.id.l2);
    uptodown = AnimationUtils.loadAnimation(this, R.anim.uptodown);
    downtoup = AnimationUtils.loadAnimation(this, R.anim.downtoup);
    l1.setAnimation(uptodown);
    l2.setAnimation(downtoup);
    startActivity(intent); //<<<<<<<<<<<<<<,
l1=(LinearLayout)findviewbyd(R.id.l1);
l2=(线性布局)findViewById(R.id.l2);
uptown=AnimationUtils.loadAnimation(this,R.anim.uptown);
downtoup=AnimationUtils.loadAnimation(this,R.anim.downtoup);
l1.设置动画(向上向下);
l2.设置动画(向下);
星触觉(意向)// 试着改变一下顺序

    l1 = (LinearLayout) findViewById(R.id.l1);
    l2 = (LinearLayout) findViewById(R.id.l2);
    uptodown = AnimationUtils.loadAnimation(this, R.anim.uptodown);
    downtoup = AnimationUtils.loadAnimation(this, R.anim.downtoup);
    l1.setAnimation(uptodown);
    l2.setAnimation(downtoup);
    startActivity(intent); //<<<<<<<<<<<<<<,
l1=(LinearLayout)findviewbyd(R.id.l1);
l2=(线性布局)findViewById(R.id.l2);
uptown=AnimationUtils.loadAnimation(this,R.anim.uptown);
downtoup=AnimationUtils.loadAnimation(this,R.anim.downtoup);
l1.设置动画(向上向下);
l2.设置动画(向下);
星触觉(意向)//