Hello, ๋‚˜๋‚˜'s world !

(Lottie ๋กœํ‹ฐ) Android์—์„œ Lottie ์‚ฌ์šฉํ•˜๊ธฐ ๋ณธ๋ฌธ

๐Ÿ’š Android

(Lottie ๋กœํ‹ฐ) Android์—์„œ Lottie ์‚ฌ์šฉํ•˜๊ธฐ

Nana0 2021. 1. 20. 07:04

 

 

 

Lottie๋ž€ Airbnb(์—์–ด๋น„์•ค๋น„)์—์„œ ๋งŒ๋“ค์—ˆ๊ณ  ์‹ค์‹œ๊ฐ„์œผ๋กœ After Effect ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋ Œ๋”๋ง, iOS์™€ ์•ˆ๋“œ๋กœ์ด๋“œ, React Native์—์„œ ๋™์ž‘ํ•˜๋Š” ๊ณ ํ’ˆ์งˆ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋‹ค.

 

JSON ํŒŒ์ผ์„ ๋‹ค์šด๋ฐ›๊ณ  ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค์˜ assets ํด๋”์— ์ €์žฅํ•ด ์‚ฌ์šฉํ•œ๋‹ค. 

 

lottiefiles.com/

Featured animations from our community

Featured collection of Free Lottie Animations created with Bodymovin.

lottiefiles.com

 

ํ•„์ž๋Š” Lottie๋ฅผ ์‚ฌ๋ž‘ํ•œ๋‹ค !! (๊ทธ๋ ‡๋‹ค๊ณ  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋งŽ์ด ์“ฐ๋Š”๊ฑด ์ข‹์ง€์•Š๋‹ค.)

assets ํด๋”์— JSON์„ ์ถ”๊ฐ€ํ•˜์ง€ ์•Š์•„๋„ GIF ๋กœ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ณ , ์• ๋‹ˆ๋ฉ”์ด์…˜๋“ค์„ ๊ฐ ์ด๋ฏธ์ง€ ๋ ˆ์ด์–ด์˜ ์ƒ‰์ƒ, ์†๋„, ๋ฐฐ๊ฒฝ์ƒ‰ ๋“ฑ์„ ์ปค์Šคํ…€ ํ•  ์ˆ˜ ์žˆ๋Š” ๋“ฑ๋“ฑ์˜ ์ด์œ ์ด๋‹ค.

์นด์นด์˜คํ†ก ๋ฐฐ๊ฒฝํ™”๋ฉด์— ๋ˆˆ๋‚ด๋ฆฌ๋Š” ํ™”๋ฉด, ๋™์ ์ธ ์Šคํ”Œ๋ž˜์‹œ ํ™”๋ฉด, ๊ฝƒ๊ฐ€๋ฃจ๊ฐ€ ๋‚ ๋ฆฌ๋Š” ์„ ๋ฌผ์ƒ์ž ๋ฒ„ํŠผํšจ๊ณผ ๋“ฑ๋“ฑ.. UI์— ํ™œ์šฉํ• ๊ณณ์ด ์—„์ฒญ ๋งŽ๋‹ค!

 

 

๋กœํ‹ฐ์˜ 2020๋…„์„ ๋ชจ์•„๋ณด๋Š” ๋งํฌ์ด๋‹ค~

lottiefiles.com/2020-year-in-motion?utm_source=email&utm_medium=email&utm_campaign=year_in_motion

Year in Motion 2020

2020 has been a bit of a roller coaster, but it was nothing if not memorable. We want to end this year by highlighting achievements and top moments that make us proud to do what we do.

lottiefiles.com

 

 

 

 

 

๊ทธ๋Ÿผ ๊ฐ„๋‹จํ•˜๊ฒŒ ์Šคํ”Œ๋ž˜์‹œ ํ™”๋ฉด์— ์ ์šฉํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ๋‹ค.

 

 

 

1. build.gradle

implementation 'com.airbnb.android:lottie:3.5.0'

 

2. activity_splash.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/splash_background">

    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/splash_lottie"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:lottie_fileName="splash.json"
        app:lottie_loop="true"
        app:lottie_autoPlay="true"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/first_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="@id/splash_lottie"
        android:layout_marginTop="410dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="50dp"
        style="@style/Splash_tv"
        android:text="์“ฑ์‹น์“ฑ์‹น"
        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="@id/first_tv"
        android:layout_marginTop="100dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginRight="50dp"
        style="@style/Splash_tv"
        android:text="์‹ฌ๋ฆฌ ํ…Œ์ŠคํŠธ"
        />


</androidx.constraintlayout.widget.ConstraintLayout>

 

 

3. SplashActivity.java

 

public class SplashActivity extends AppCompatActivity {
    private Handler mHadler = new Handler();
    private View mDecorView;
    private int	mUiOption;
    private ImageView mImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //์ƒ๋‹จ ์ƒํƒœ๋ฐ” ์—†์• ๊ธฐ onCreate์•„๋ž˜ ๋ฐ”๋กœ ์ž‘์„ฑ
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_splash);
        //ํ•˜๋‹จ ์†Œํ”„ํŠธํ‚ค ์—†์• ๊ธฐ
        mDecorView = getWindow().getDecorView();
        mUiOption = getWindow().getDecorView().getSystemUiVisibility();
        if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH )
            mUiOption |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN )
            mUiOption |= View.SYSTEM_UI_FLAG_FULLSCREEN;
        if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT )
            mUiOption |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

        mDecorView.setSystemUiVisibility( mUiOption );

        //์Šคํ”Œ๋ž˜์‰ฌ ํ•ธ๋“ค๋Ÿฌ
        mHadler.postDelayed(new SplashHandler(), 4000);

        final LottieAnimationView mANIMATION_VIEW = (LottieAnimationView) findViewById(R.id.splash_lottie);
        mANIMATION_VIEW.addAnimatorListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {

            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });


    }

    private class SplashHandler implements Runnable{
        public void run(){
            startActivity(new Intent(getApplication(), MainActivity.class));
            SplashActivity.this.finish();
        }

    }
    
    //์Šคํ”Œ๋ž˜์‹œ ํ™”๋ฉด์—์„œ ๋„˜์–ด๊ฐˆ๋•Œ ๋’ค๋กœ๊ฐ€๊ธฐ ๋ง‰๊ธฐ
    public void onBackPressed(){

    }
}

 

 

4. assert ํด๋” ์ถ”๊ฐ€ํ›„ ๋‹ค์šด๋ฐ›์€ JSON ํŒŒ์ผ์„ assert ํด๋” ์•„๋ž˜์— ๋„ฃ๋Š”๋‹ค.

 

 

 

 

 

5. AndroidManifest.xml

 

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/main_icon"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/main_icon"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar">
        <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"/>

    </application>

</manifest>

 

 

 


 

๐ŸŽ‰ ์™„์„ฑ ๐ŸŽ‰

 

 

<์™„์„ฑ ํ™”๋ฉด>

 

 

 

 

 


<๊ฐœ๋ฐœํ™˜๊ฒฝ>

java version "1.8.0_271"

android API 10.0.0+ (R)

android studio "4.0.1"

 

 

<์ฐธ์กฐ>

onlyfor-me-blog.tistory.com/127

Comments