I am trying to get a Image to fade at the start of an application without having to press a button. I have been looking around but it seems as if for some reason that people only know how to make it so that you need a button to make the image or object to perform the animation. I do have a animation file ready. The problem is getting the image to fade without a button.
package android.example.verification;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
MediaPlayer mysong;
private View image;
ImageView imageView;
Animation animation;
private Object TitleScreen;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG,"onCreate: started.");
mysong = MediaPlayer.create(MainActivity.this, R.raw.bc);
mysong.start();
mysong.setLooping(true);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//Logo
int imageResource = getResources().getIdentifier("@drawable/logo", null, this.getPackageName());
ImageView firstImage = (ImageView) findViewById(R.id.firstImage);
firstImage.setImageResource(imageResource);
}
//Logo Fade Animation
public void tapToFade(View view) {
Button button = (Button)findViewById(R.id.firstImage);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.fade);
button.startAnimation(animation);
}
//helps Music
@Override
protected void onPause() {
super.onPause();
mysong.release();
finish();
}
}