当我们从下到上向上滚动协调器布局时,我需要向下滚动应用程序顶部栏从顶部到几英寸。我试图为顶部条形图设置动画,但只有在coodinator布局折叠完成后它才会动画化。请建议我如何动画这个。
Toolbar toolbar_transtat_dash;
AppBarLayout.OnOffsetChangedListener offsetChanged = new
AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset > -300) {
toolbar_transtat_dash.setVisibility(View.VISIBLE);
opacity_change = ((float) Math.abs(verticalOffset) / appBarLayout_dash.getTotalScrollRange());
toolbar_transtat_dash.setAlpha(opacity_change);
toolbar_transtat_dash.setTranslationY(-toolbar_transtat_dash.getHeight());
toolbar_transtat_dash.animate().translationY(0).setDuration(1500).start();
}
}
};