[JAVA] [Android] [Library] I tried using an animation library called "Before After animation".

1.First of all

An animation library written in Kotlin called "Before After animation" is available in "Before After animation library write in Kotlin in Android Example 365. -after-animation-library-write-in-kotlin /) "was published, so I tried using it.

2. Usage image

Move the slide from left to right to gradually switch images.

--Before moving

1lmitbduqj.png

--After moving

vke0vpixjy.png

3. Advance preparation

Please prepare the following in advance.

-Android Studio with Kotlin plugin installed

4. Setup procedure

4.1 Editing build.gradle

Add the following to the build.gradle of the project.

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }   //Postscript
}

Add the following to the module build.gradle.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    // Before After animation library                                         //Postscript
    implementation 'com.github.fevziomurtekin:BeforeAfterView:1.0.0'          //Postscript
}

4.2 Activity description

Describe the MainActivity.

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}

4.3 Layout file description

Describe the following in res / layout / activitymain.xml.

  <com.fevziomurtekin.beforeafterview.BeforeAfterView
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           app:bgColor="@android:color/black"
           app:sliderTintColor="@android:color/white"
           app:sliderIconTint="@android:color/white"
           app:afterSrc="@drawable/after"
           app:beforeSrc="@drawable/before"
           app:imageHeightPercent="0.5"
           app:sliderWidthPercent="0.75"
   />

You can edit the attributes as follows:

ATTRIBUTE DESCRIPTION
bgColor The color in int of the background color (by default @android:color/black)
sliderTintColor The color int of the slider tint color (by default @android:color/white)
sliderIconTint The size in int of the slider icon color (by default @android:color/white)
afterSrc The resource in int of the imageview src
beforeSrc The resource in int of the imageview src
imageHeightPercent The height percent of the imageView (by default 0.55f)
sliderWidthPercent The width percent of the sliderView (by default 0.65f)

4.4 Image file preparation

Under res / drawable, after.jpg and before.jpg of the image source specified in the layout are stored. Please have an image ready. However, if the image file is large, an error will occur when reading it.

5. Source

The source is published on Github.

zxicx39v2q.pngfevziomurtekin/BeforeAfterView

The Apache License 2.0 license.

6. At the end

Now you can easily create an image animation. Why don't you try it by incorporating it into your project or customizing the animation?

update information

Recommended Posts

[Android] [Library] I tried using an animation library called "Before After animation".
[Android] I tried using Coordinator Layout.
I tried using the CameraX library with Android Java Fragment
I tried using Gson
I tried using TestNG
I tried using Galasa
I tried using a database connection in Android development
I tried using an extended for statement in Java
I tried to build an environment using Docker (beginner)
I tried using the GitHub repository as a library server
I tried to make Venn diagram an easy-to-understand GIF animation
I tried using azure cloud-init
I tried to introduce UI animation to Pokedex using Poké API
I tried using Apache Wicket
After learning Progate, I tried to make an SNS application using Rails in the local environment
I tried to make an Android application with MVC now (Java)
I tried to make it an arbitrary URL using routing nesting
I tried using anakia + Jing now
I tried something called recursive search
I tried using Spring + Mybatis + DbUnit
I tried using JOOQ with Gradle
I tried using Java8 Stream API
I tried using JWT in Java
I tried using Pari gp container
I tried using WebAssembly Stadio (2018/4/17 version)
I tried using Java memo LocalDate
I tried using GoogleHttpClient of Java
I tried to make a simple face recognition Android application using OpenCV
I tried to summarize the stumbling points when developing an Android application
Make an executable jar using Android Studio
I tried using Elasticsearch API in Java
I tried using Realm with Swift UI
I tried using Java's diagnostic tool Arthas
I tried using UICollectionViewListCell added from Xcode12.
I tried using Scalar DL with Docker
I tried using OnlineConverter with SpringBoot + JODConverter
It's new, but I tried using Groonga
I tried the AutoValue library in Intellij
I tried using "nifty cloud mobile backend" and "Firebase" Authentication on Kotlin + Android