How change ActionBar colour when swiping between fragments (Material Design)?

后端 未结 2 758
无人共我
无人共我 2020-12-09 07:09

I have an app i am doing, which has a FragmentPagerAdapter setup with 3 fragments to swipe between on the main page.

I have been trying to get it setup so as you swi

2条回答
  •  猫巷女王i
    2020-12-09 07:42

    You could make your FragmentPagerAdapter implements ViewPager.OnPageChangeListener.

    Then, override onPageSelected

    @Override
    public void onPageSelected(int position) {
        // get the action bar here and change color
    }
    

    As for the color change animation. I didn't try it, but this is from another stackoverflow issue :

    Android objectAnimator animate backgroundColor of Layout

提交回复
热议问题