我目前有一个列表视图,其中包含页眉和页脚。我现在试图为列表本身内的项目设置动画,但是当我将LayoutAnimationController
应用到列表视图时,标题也是动画的。有没有办法将动画应用到整个列表而不影响标题?将动画添加到标题中而不对标题应用动画效果
我目前已经在Can LayoutAnimationController animate only specified Views上尝试过使用LinearLayout子类来检查动画,但标题仍然与其余项目一起动画。
public class AnimationAverseLinearLayout extends LinearLayout {
private boolean mIsAnimatable = true;
public AnimationAverseLinearLayout(Context context) {
super(context);
}
public AnimationAverseLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setAnimatable(boolean isAnimatable) {
if(!isAnimatable)
clearAnimation();
mIsAnimatable = isAnimatable;
}
@Override
public void startAnimation(Animation animation) {
if(mIsAnimatable) {
super.startAnimation(animation);
}
}
}
....
//in onCreateView
ListView listView = (ListView) v.findViewById(android.R.id.list);
listView.setLayoutAnimation(Animations.animateListView(listView.getContext()));
header = (com.yardi.hud.inspections.util.AnimationAverseLinearLayout) inflater.inflate(R.layout.fragment_case_search_header, null, false);
header.setAnimatable(false);
listView.addHeaderView(header);
...
SearchAdapter adapter = new SearchAdapter(results);
setListAdapter(adapter);
是否有一些GIF视频相似,看看你想要实现什么样的动画? – nKn
你在这里有什么进展吗?我的答案有帮助吗? :) – MatheusJardimB
动画类型不重要,因为任何动画都会以同样的方式影响视图。尽管如此,我正在对视图做一个alpha/translate集。 而Matheus,我唯一的进步就是将动画移动到了包装好的适配器的getView中,但它并不理想,因为这样做会在您滚动时动画所有视图,这在300的列表中可能太过压倒结果 – GrouchyPanda