答案 0 :(得分:0)
我认为没有动态主题应用于那里。 viewpager中的每个片段都有其主题元素,具体取决于它们的主题。如果你想知道工具栏动画是如何完成的,我可以建议一种能给你相同结果的方法。
播放商店布局
<Toolbar>
<FrameLayout>
<RelativeLayout id="toolbarContainer">
</RelativeLayout>
<RelativeLayout id="revealContainer">
</RelativeLayout>
<TabLayout></TabLayout>
</FrameLayout>
</Toolbar>
<StoreView></StoreView><!-- This is where you see viewpager fragments -->
过程将是:
代码看起来像这样
viewPager.setOnPageChangeListener(new OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
public void onPageSelected(int position) {
// new position of page
showRevealEffectForPage(position);
}
});
private void showRevealEffectForPage(int page) {
int color;
switch(page) {
case 0:
color = Color.parseColor("#fff"); //white
break;
default:
color = Color.parseColor("#000"); //black
break;
}
//set color before animation starts
revealContainer.setBackgroundColor(color);
int x = revealContainer.getRight();
int y = revealContainer.getBottom();
int startRadius = 0;
int endRadius = (int) Math.hypot(toolbarContainer.getWidth(), toolbarContainer.getHeight());
Animator anim = ViewAnimationUtils.createCircularReveal(revealContainer, x, y, startRadius, endRadius);
layoutButtons.setVisibility(View.VISIBLE);
// you can set animation listener here to check for when the animation ends by
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
//set the color of toolbarContainer
toolbarContainer.setBackgroundColor(color);
revealContainer.setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
anim.start();
}