我有一个设置首选项屏幕,我从另一个屏幕打开该屏幕并自动滚动到特定的设置首选项,但我想向滚动的首选项添加闪烁/闪烁动画,以便用户引起注意。
应该就像我们打开Android设置屏幕并搜索设置时一样,打开设置时它会突出显示。
我研究了多个地方,但没有找到相关的。
我已经用这段代码做到了。
new Thread(() -> {
requireActivity().runOnUiThread(() -> {
Preference myPreference = findPreference("myPreference");
View myView = getListView().getChildAt(swRecrearNotificacion.getOrder() + 1);
BlinkView(myView , 10);
});
}).start();
public void BlinkView(View oView, int iNumberOfRepetitions) {
if (oView == null) return;
final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
animation.setDuration(80);
animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
animation.setRepeatCount(iNumberOfRepetitions);
animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in
oView.startAnimation(animation);
}