芯片导航条动画不工作

问题描述 投票:0回答:1

我在底部导航的代码中使用了这个GitHub库。芯片导航条我试着让它在启动程序后浮起来,但当运行程序时,它消失了,但当点击按钮时,点击监听器工作,但我无法看到导航栏,这是点击监听器。

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btmNav = findViewById(R.id.btmNav);
    layout = findViewById(R.id.cntBTM);
    animMove = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);
    btmNav.startAnimation(animMove);

    //////////////*


    if (savedInstanceState == null) {
        NewsFragment newsFragment = new NewsFragment();

        fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.fragmentContainer, newsFragment)
                .commit();

    }


    btmNav.setOnItemSelectedListener(new ChipNavigationBar.OnItemSelectedListener() {
        @Override
        public void onItemSelected(int id) {
            Fragment fragment = null;
            switch (id) {
                case R.id.home:
                    fragment = new WebFragment();
                    break;
                case R.id.activity:
                    fragment = new ActivityFragment();
                    break;
                case R.id.settings:
                    fragment = new SettingFragment();
                    break;
            }
            if (fragment != null) {
                fragmentManager = getSupportFragmentManager();
                fragmentManager.beginTransaction()
                        .replace(R.id.fragmentContainer, fragment)
                        .commit();
            } else {
                Log.e(TAG, "Error in creating fragment");
            }
        }
    }); 

这是在主活动中

 <com.ismaeldivita.chipnavigation.ChipNavigationBar
    android:id="@+id/btmNav"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true"
    android:layout_margin="12dp"
    android:background="@drawable/rounded"
    android:elevation="5dp"
    android:outlineAmbientShadowColor="@color/colorAccent"
    app:cnb_menuResource="@menu/bottom_menu"
    app:cnb_unselectedColor="#fff"
android animation uinavigationbar android-bottomappbar jave
1个回答
0
投票

添加你的 build.gradle implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.72'

© www.soinside.com 2019 - 2024. All rights reserved.