我目前有一個列表視圖,其中包含頁眉和頁腳。我現在試圖爲列表本身內的項目設置動畫,但是當我將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