动画MAXLINES和Ellipsize [英] Animate MaxLines and Ellipsize
问题描述
予有TextView中,其中包含一个文本的一部分。当用户点击的箭头,所述的TextView调整大小,使全文被示出。请参阅下面的示例图像:
I have textview which contains a part of a text. When the user clicks the arrow, the textview resizes so the full text is shown. See the images below for an example:
的TextView的具有WRAP_CONTENT高度,并且当折叠一MAXLINES =4。
The TextView has a wrap_content height, and when collapsed a maxLines="4".
箭头的onclick包含此code:
The onClick of the arrow contains this code:
if (isExpanded) {
btnToggle.setImageDrawable(getResources().getDrawable(
R.drawable.arrow_down));
tvText.setMaxLines(4);
tvText.setEllipsize(TruncateAt.END);
} else {
btnToggle.setImageDrawable(getResources().getDrawable(
R.drawable.arrow_up));
tvText.setMaxLines(Integer.MAX_VALUE);
tvText.setEllipsize(null);
}
isExpanded = !isExpanded;
这code的作品,但它不是动画。我需要动画的扩大,所以TextView的动画到它的最大高度。 我无法找到像MAXLINES动画属性什么。谁可以帮我吗?
This code works, but it is not animated. I need to animate the expansion, so the TextView animates to it's full height. I can't find anything about animating properties like MaxLines. Who can help me out?
推荐答案
您可以使用此实现的 ObjectAnimator
ObjectAnimator animation = ObjectAnimator.ofInt(
tvText,
"maxLines",
25);
animation.setDuration(4000);
animation.start();
这将增加tvText的TextView无论从那个它最初被设定为的maxlines的属性,至25日,超过4000毫秒的时间。
This will increase the "maxLines" property of the "tvText" TextView from whatever it initially is set to, to 25, over the period of 4000 milliseconds.
这篇关于动画MAXLINES和Ellipsize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!