Android Studio Экран загрузки (Splash)

Опубликовано: 28 Март 2026
на канале: Coders
377
5

Splash.java

public class Splash extends AppCompatActivity {

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

final ImageView img = (ImageView) findViewById(R.id.imageView);
final Animation an = AnimationUtils.loadAnimation(getBaseContext(), R.anim.rotate);
final Animation an2 =AnimationUtils.loadAnimation(getBaseContext(), R.anim.abc_fade_out);

img.startAnimation(an);
an.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {

}

@Override
public void onAnimationEnd(Animation animation) {
img.startAnimation(an2);
finish();
Intent i = new Intent(getBaseContext(), MainActivity.class);
startActivity(i);
}

@Override
public void onAnimationRepeat(Animation animation) {

}
});
}
}

rotate.xml

android:duration="4000"
android:fromDegrees="0"
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"