在按钮动画绘制对象变化

在按钮动画绘制对象变化

本文介绍了在按钮动画绘制对象变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮具有 BitmapDrawable 并在它的文本行。不,它重要,但我可绘制是上面我的文字这将对应于从顶部的第三个按钮。

I have a Button that has a BitmapDrawable and a row of text in it. Not that it matter but my drawable is "above" my text which would correspond to the third button from the top.

的绘制是使用设置:

BitmapDrawable top = new BitmapDrawable(mContext.getResources(), Bitmap.createScaledBitmap(buttonContent.content,
            mContext.IMAGE_WIDTH, mContext.IMAGE_HEIGHT, false));

    button.setCompoundDrawablesWithIntrinsicBounds(null, top.getCurrent(), null, null);

这是我最初设置一些事件后改变和我想要的图像变化的图像进行动画。我已经有的android:animateLayoutChanges = TRUE 字段在我的布局

The image that I set initially changes after some events and I want the image change to be animated. I already have the android:animateLayoutChanges=true field in my layout.

我最初的猜测是创建一个自定义按钮级。但我不知道是否有另一种方式来解决我的问题?

My initial guess is to create a custom Button-class. But I'm wondering if there's another way to resolve my issue?

推荐答案

您可以动画绘制本身。一个。您可以使用复合可绘制该技术也是如此。


Old answer based on Animatables: See the "Drawable Animation" documentation. You can use that technique for compound drawables as well.

使用类似

((Animatable) button.getCompoundDrawables()[INDEX]).start();

或持有到设置动画当没有设置的XML的绘制。参照

or hold a reference to the Animatable when not setting the drawable from XML.

这篇关于在按钮动画绘制对象变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 13:31