razir / ProgressButton

Android Progress Button
856 stars 78 forks source link

[Question] - Image instead of Text #17

Closed GuilhE closed 4 years ago

GuilhE commented 4 years ago

The idea is to have a "submit" image, a progress animation (already provided by your lib) and a "finish" image. Does your lib allow us to have an image instead of "submit text"?

Using your sample I cannot:

buttonProgressMixed.showDrawable(ContextCompat.getDrawable(this, R.drawable.ic_chevron_right_black_24dp)!!)
buttonProgressMixed.setOnClickListener {
    showMixed(buttonProgressMixed)
}

private fun showMixed(button: Button) {
        val animatedDrawable = ContextCompat.getDrawable(this, R.drawable.animated_check)!!
        val drawableSize = resources.getDimensionPixelSize(R.dimen.doneSize)
        animatedDrawable.setBounds(0, 0, drawableSize, drawableSize)

        button.showProgress {
            progressColor = Color.WHITE
            gravity = DrawableButton.GRAVITY_CENTER
        }
        button.isEnabled = false

        Handler().postDelayed({
            button.isEnabled = true
            button.showDrawable(animatedDrawable) { gravity = DrawableButton.GRAVITY_CENTER }
        }, 3000)
    }

It shows the loading animation, the finish animation, but not the "star/idle" drawable. Why?

GuilhE commented 4 years ago

Ok I was missing the setBounds