【问题标题】:chip navigation bar animation not works芯片导航栏动画不起作用
【发布时间】:2020-08-09 18:11:28
【问题描述】:

我在代码中使用这个 GitHub 库进行底部导航。chip navigation bar 我试图在启动程序后让它浮起来。但是当运行程序时它消失了,但是当点击按钮的地方时。点击监听器工作,但我看不到导航栏 这是点击监听器;

 @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】:

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

    【讨论】:

    • 我之前加的。
    【解决方案2】:

    使用这个库https://github.com/ismaeldivita/chip-navigation-bar

    不要忘记在 settings.graddle 中添加 maven

    maven { url 'https://jitpack.io' }
    

    不要忘记将此依赖项添加到您的 build.graddle 文件中

        implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.6.0'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-15
      • 2019-02-20
      • 1970-01-01
      • 2015-12-25
      相关资源
      最近更新 更多