【发布时间】:2019-07-18 22:47:43
【问题描述】:
我的应用程序中有一个列表视图,我希望能够滚动到列表视图中的某个位置,然后在该条目处执行闪烁动画以向用户突出显示它。
我遇到的问题是,如果滚动到的条目位于列表视图的视图之外,则不会发生闪烁动画。我知道列表视图很有效,因为它不会一次加载所有条目,所以这可能是动画没有发生的原因。我该如何解决这个问题?
滚动到代码:
//Changes to tab with listview
tabLayout.getTabAt(1).select();
//Get index to scroll to
int selectIndex = whitelistFragment.getWhitelistTableHelper().getListViewEntryIndex(entryString);
//If the entry exists
if(selectIndex != -1) {
//Scroll to index
whitelistFragment.getWhitelistTableHelper().getListView().setSelection(selectIndex);
//Make entry blink several times
View entryView = helperFunctions.getViewByPosition(selectIndex, whitelistFragment.getWhitelistTableHelper().getListView());
Animation blinkAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);
entryView.startAnimation(blinkAnimation);
}
Blink.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="600"
android:repeatMode="reverse"
android:repeatCount="5"/>
</set>
【问题讨论】:
标签: android android-listview android-animation