Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried the drawable animation in android but it did not work. I am following this website code because it was I want exactly Drawable animation in the android Kotlin tutorial.

What I have tried:

I have tried images of all dimensions but no use. I am getting a static image.

import android.graphics.Color
import android.graphics.drawable.AnimationDrawable
import android.os.Bundle
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

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

        view.setBackgroundColor(Color.parseColor("#737373"))

        imageView.setBackgroundResource(R.drawable.gube)
        val ani = imageView.getBackground() as AnimationDrawable
    }
}
Posted
Updated 11-Jun-20 21:45pm

1 solution

You missed out the line of code that starts the animation. Read carefully Drawable animation in the android Kotlin tutorial. - Warmodroid[^].
 
Share this answer
 
Comments
Member 14820609 12-Jun-20 3:49am    
Hey Richard, Thanks for the quick help. It Really saved my day.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900