Hello, ๋๋'s world !
(Lottie ๋กํฐ) Android์์ Lottie ์ฌ์ฉํ๊ธฐ ๋ณธ๋ฌธ
Lottie๋ Airbnb(์์ด๋น์ค๋น)์์ ๋ง๋ค์๊ณ ์ค์๊ฐ์ผ๋ก After Effect ์ ๋๋ฉ์ด์ ์ ๋ ๋๋ง, iOS์ ์๋๋ก์ด๋, React Native์์ ๋์ํ๋ ๊ณ ํ์ง ์ ๋๋ฉ์ด์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค.
JSON ํ์ผ์ ๋ค์ด๋ฐ๊ณ ์๋๋ก์ด๋ ์คํ๋์ค์ assets ํด๋์ ์ ์ฅํด ์ฌ์ฉํ๋ค.
ํ์๋ Lottie๋ฅผ ์ฌ๋ํ๋ค !! (๊ทธ๋ ๋ค๊ณ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ง์ด ์ฐ๋๊ฑด ์ข์ง์๋ค.)
assets ํด๋์ JSON์ ์ถ๊ฐํ์ง ์์๋ GIF ๋ก๋ ์ฌ์ฉํ ์ ์๊ณ , ์ ๋๋ฉ์ด์ ๋ค์ ๊ฐ ์ด๋ฏธ์ง ๋ ์ด์ด์ ์์, ์๋, ๋ฐฐ๊ฒฝ์ ๋ฑ์ ์ปค์คํ ํ ์ ์๋ ๋ฑ๋ฑ์ ์ด์ ์ด๋ค.
์นด์นด์คํก ๋ฐฐ๊ฒฝํ๋ฉด์ ๋๋ด๋ฆฌ๋ ํ๋ฉด, ๋์ ์ธ ์คํ๋์ ํ๋ฉด, ๊ฝ๊ฐ๋ฃจ๊ฐ ๋ ๋ฆฌ๋ ์ ๋ฌผ์์ ๋ฒํผํจ๊ณผ ๋ฑ๋ฑ.. UI์ ํ์ฉํ ๊ณณ์ด ์์ฒญ ๋ง๋ค!
๋กํฐ์ 2020๋ ์ ๋ชจ์๋ณด๋ ๋งํฌ์ด๋ค~
lottiefiles.com/2020-year-in-motion?utm_source=email&utm_medium=email&utm_campaign=year_in_motion
๊ทธ๋ผ ๊ฐ๋จํ๊ฒ ์คํ๋์ ํ๋ฉด์ ์ ์ฉํด๋ณด๋๋ก ํ๊ฒ ๋ค.
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
'๐ Android' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
android TMDB ์ฌ์ฉํ๊ธฐ (0) | 2021.02.05 |
---|---|
Android Waveํจ๊ณผ ๋ฃ๊ธฐ WaveView (0) | 2021.01.20 |
Fragment์ RecyclerView ์์ Fragment๋ก ๋ฐ์ดํฐ ์ ๋ฌํ๊ธฐ (0) | 2021.01.20 |
dialogFragment ์์ Fragment ๋ก ๋ฐ์ดํฐ ์ ๋ฌ (0) | 2021.01.18 |
onDraw() ๋ฅผ ํ์ฉํ์ฌ ๊ทธ๋ฆผ๊ทธ๋ฆฌ๊ธฐ (0) | 2021.01.08 |