티스토리 뷰

1. fade in 애니메이션 만들기

 

res에 anim 폴더를 만든다.

 

그 후 fade_in 애니메이션을 만든다.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
    <alpha
        android:duration="1000"
        android:fromAlpha="0.0"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toAlpha="1.0" />
</set>

 

2.Splash activity 만들기

 

package bns.co.kr.buddybot.braintraining;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

public class Splash extends AppCompatActivity {
    Animation anim;
    LinearLayout linearLayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
              //  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 화면 가로 고정
        setContentView(R.layout.activity_splash);
        linearLayout=(LinearLayout)findViewById(R.id.activity_splash); // Declare an imageView to show the animation.
        anim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in); // Create the animation.
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                startActivity(new Intent(Splash.this,GameFragmentManager.class));
                // HomeActivity.class is the activity to go after showing the splash screen.
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        linearLayout.startAnimation(anim);
    }
}

2020/03/12 - [인턴/안드로이드] - 안드로이드 가로 화면 지정하기

 

안드로이드 가로 화면 지정하기

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 를 코드에 추가해주면 된다. 아래와 같이 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstance..

15051015.tistory.com

3. activity_splash.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:id="@+id/activity_splash"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/splash">
</LinearLayout>

 

 

 

4.manifast 등록하기

 

        <activity
            android:name=".Splash"
            android:theme="@style/Theme.AppCompat.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

2020/03/12 - [인턴/안드로이드] - 안드로이드 액션바 없애기 ( 기본 제목 없애기 )

 

안드로이드 액션바 없애기 ( 기본 제목 없애기 )

엑티비티의 경우 manifests에 등록을 해주어야 작동한다. 이 경우에 manifests에서 기본 제목 ( 액션바 ) 를 없앨 수 있는데 android:theme="@style/Theme.AppCompat.NoActionBar"> 를 추가해 주면 해당하는 엑티..

15051015.tistory.com

이걸 manifast에 추가한다.

 

그 후 원래있던 

 

<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>

 

를 지우면 초기화면이 main에서 Splash로 바뀐다.

 

 

 

이렇게하면 자신이 원하는 이미지가 fade_in 이 끝난 후 다음 엑티비티를 실행한다.

 

 

댓글
최근에 올라온 글
최근에 달린 댓글
250x250