Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

java - How do I turn off the Meow Bottom bar animation?

I need to disable transition animation for Meow Bottom Bar written in Java, that is, for

'com.etebarian: meow-bottom-navigation-java:1.2.0'

I tried toggling animation via * setAnimation () * unfortunately it didn't work. I also searched the documentation for this library, but I did not find anything related to animation. Can you please help me? My Bottom Bar code is below

Bottom Bar Code

    MeowBottomNavigation bottomNavigationBar = findViewById(R.id.bottom_navigation_bar);

    bottomNavigationBar.add(new MeowBottomNavigation.Model(ID_HOME, R.drawable.svg_home));
    bottomNavigationBar.add(new MeowBottomNavigation.Model(ID_MESSAGE, R.drawable.svg_message));
    bottomNavigationBar.add(new MeowBottomNavigation.Model(ID_NOTIFICATIONS, R.drawable.svg_notifications));
    bottomNavigationBar.add(new MeowBottomNavigation.Model(ID_SETTINGS, R.drawable.svg_setting));

    } catch (Exception error) {
        Log.e(TAG, error.toString());
    }
    bottomNavigationBar.setOnClickMenuListener(new MeowBottomNavigation.ClickListener() {
        @Override
        public void onClickItem(MeowBottomNavigation.Model item) {
            try {
                switch (item.getId()) {
                    default:
                        Log.d(TAG, "switch default meow bottom bar");
                        break;
                    case ID_TASKS:
                        startActivity(new Intent(getApplicationContext(), HomeActivity.class));
                        finish();
                        overridePendingTransition(0, 0);
                        break;
                    case ID_CLOCK:
                        startActivity(new Intent(getApplicationContext(), MessageActivity.class));
                        finish();
                        overridePendingTransition(0, 0);
                        break;
                    case ID_CALENDAR:
                        startActivity(new Intent(getApplicationContext(), NotificationsActivity.class));
                        finish();
                        overridePendingTransition(0, 0);
                        break;
                    case ID_SETTINGS:
                        startActivity(new Intent(getApplicationContext(), SettingActivity.class));
                        finish();
                        overridePendingTransition(0, 0);
                        break;

                }
            } catch (Exception error) {
                Log.e(TAG, error.toString());
            }
        }
    });
    bottomNavigationBar.setOnShowListener(new MeowBottomNavigation.ShowListener() {
        @Override
        public void onShowItem(MeowBottomNavigation.Model item) {
            try {
                Log.i(TAG, "bottomNavigationBar ShowListener");
            } catch (Exception error) {
                Log.e(TAG, error.toString());
            }
        }
    });

    bottomNavigationBar.setOnReselectListener(new MeowBottomNavigation.ReselectListener() {
        @Override
        public void onReselectItem(MeowBottomNavigation.Model item) {
            try {
                Log.i(TAG, "bottomNavigationBar ReselectListener");
            } catch (Exception error) {
                Log.e(TAG, error.toString());
            }
        }
    });
    bottomNavigationBar.show(ID_HOME);

I want to switch between activities this way

Bottom Bar XML

<com.etebarian.meowbottomnavigation.MeowBottomNavigation
    android:id="@id/bottom_navigation_bar"
    style="@style/MyBottomNavigation"/>

Bottom Bar Style

<style name="MyBottomNavigation">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="mbn_backgroundBottomColor">?android:windowBackground</item>
    <item name="mbn_circleColor">?colorSecondary</item>
    <item name="mbn_defaultIconColor">?colorSecondary</item>
    <item name="mbn_selectedIconColor">?colorPrimary</item>
    <item name="mbn_shadowColor">?colorAccent</item>
</style>
question from:https://stackoverflow.com/questions/66063051/how-do-i-turn-off-the-meow-bottom-bar-animation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think you have to set has_animation attribute to false to disable animation, add <item name="mbn_hasAnimation">false</item> to your bottom nav style

<style name="MyBottomNavigation">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="mbn_backgroundBottomColor">?android:windowBackground</item>
    <item name="mbn_circleColor">?colorSecondary</item>
    <item name="mbn_defaultIconColor">?colorSecondary</item>
    <item name="mbn_selectedIconColor">?colorPrimary</item>
    <item name="mbn_shadowColor">?colorAccent</item>
    <item name="mbn_hasAnimation">false</item>
</style>

As you can see inside class MeowBottomNavigation, you will find duration is set to 1L if hasAnimation is false

line 273:: val animDuration = if (enableAnimation && hasAnimation) d else 1L

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...