问题描述
我有一个的ListView
。最初,的ListView
包含了一些数据。当用户点击在项目上,另一布局将被动态地添加到该项目,所以它的高度会增加。
I have a ListView
. Initially, the ListView
contains some data. When the user clicks on an item, another layout will be dynamically added to that item so it's height will be increased.
目前,在该项目的高度增加,这显示了修改后的项目迅速。然而,我想要的是这是动画所以它逐渐增加项目的高度。
Right now, when the item's height is increased, it shows the modified item instantly. However, what I want is for this to be animated so it increases the item's height gradually.
推荐答案
我觉得我一直在寻找一样被问,我一直在寻找一种方式来制作动画列表视图项目的不断扩大,但一些新的内容显示(我只是改变从去VISABLE)的一些看法的知名度。我曾用mirroredAbstraction的答案,帮我申请一个翻译的动画(我不想一个旋转的动画):
I think I was looking for the same as was asked, I was looking for a way to animate the expanding of the listview item as some new content is shown (I was just changing the visibility on some views from GONE to VISABLE). I had used the answer by mirroredAbstraction to help me apply a translate animation (I didn't want a rotate animation):
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fromYDelta="0"
android:toYDelta="-100%p"
android:duration="500"
/>
到每个意见。它创建一个很好的效果,但密切关注,该ListView项实际上是突然扩大到将需要整个大小,那么动画下降的看法到位。但我想要的是列表视图项的影响日益下降的观点进入的知名度。
to each of the views. It create a nice effect, but looking closely, the listview item was actually suddenly expanding to the entire size that would be needed, then the animation dropped the views into place. But what I wanted was the effect of the listview item growing down as the views come into visibility.
我发现正是我一直在寻找在这里:<一href="http://udinic.word$p$pss.com/2011/09/03/expanding-listview-items/">expanding-listview-items
I found exactly what I was looking for here:expanding-listview-items
该博客有一个链接到自己的github上的样品,在这里:ExpandAnimationExample
The blogger has a link to his github sample, here:ExpandAnimationExample
如果你发现这些网站消失了,请告诉我,我会让我的副本可用。
If you find these sites gone, please inform me and I will make my copy available.
他把阴性切缘上的内容接触到的知名度,并设置能见度GONE:
he put a negative margin on the content to come into visibility as well as setting visibility to GONE:
android:layout_marginBottom="-50dip"
和写了动画操作下边距:
and wrote an animation manipulating the bottom margin:
public class ExpandAnimation extends Animation {
...
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
if (interpolatedTime < 1.0f) {
// Calculating the new bottom margin, and setting it
mViewLayoutParams.bottomMargin = mMarginStart
+ (int) ((mMarginEnd - mMarginStart) * interpolatedTime);
// Invalidating the layout, making us seeing the changes we made
mAnimatedView.requestLayout();
}
...
}
}
和它看起来非常漂亮。我发现他的回答此等问题(可能重复):
and it looks very nice. I found his answer to this SO (possible duplicate?) question:
Adding动画到ListView以展开/折叠内容
此外,请让我知道如果你知道另一种方式做同样的事情。
Also, please let me know if you know another way to do the same thing.
这篇关于扩大与动画ListView项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!