我正在构建一个我有BottomNavigationView的应用程序.一切正常,直到我进入活动.
导航是这样的:
问题是它有这个默认动画,因此它每次都会推动活动元素高于其余元素.
另一个例子:
所以我的问题是如何摆脱这个默认动画,当我在它们之间切换时,每个项目都是对齐的?
我的代码:
public class MainActivity extends AppCompatActivity {
    private BottomNavigationView bottomNavigationView;
    private Fragment fragment;
    private FragmentManager fragmentManager;
    private FragmentTransaction transaction;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setupBottomBar();
    }
    private void setupBottomBar() {
        bottomNavigationView = (BottomNavigationView)findViewById(R.id.bottomBar);
        fragmentManager = getSupportFragmentManager();
        fragment = new CardDeckFragment();
        transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.activity_main, fragment).commit();
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()){
                    case R.id.action_card_deck:{
                        Toast.makeText(MainActivity.this, "Card Deck Selected", Toast.LENGTH_SHORT).show();
                        fragment = new CardDeckFragment();
                        break;
                    }
                    case R.id.action_favorites:{ …我已在项目中的Design Support Library 25中实现了Bottom Navigation View.我在视图中有5个图标.每当选择一个图标时,它就会有一些动画.但是当3个或更少的图标没有显示任何动画时.我想删除该动画,只需要对图标进行一些颜色更改.我怎样才能做到这一点?做了足够的谷歌搜索,但找不到解决方案.请帮忙.谢谢.
icons animation android bottomnavigationview android-bottomnav
如何根据谷歌新指南(纯机器人)实现底部导航选项卡.有什么例子吗?
参考:https://www.google.com/design/spec/components/bottom-navigation.html
android android-design-library bottomnavigationview android-bottomnav
我正在使用Google的支持设计库v25.1.0在Android应用中实现Bottom Navigation Bar.有没有办法添加阴影效果,与当前Android原生Google照片应用相同?
android android-support-library android-support-design android-bottomnav
所以我有一个正在撰写的应用程序,它已将 startDestination 设置为带有脚手架的屏幕,底部导航栏有 3 个项目和顶部应用程序栏,我可以在 3 个底部导航选项卡中导航。但是假设我想单击底部选项卡屏幕之一中的一张卡片,该卡片应该打开一个没有底部栏和应用程序栏的详细信息屏幕(由于 Navhost 位于脚手架内,底部和顶部栏也会显示在详细信息屏幕上),什么这样做的正确方法是什么?目前我已尝试以下方法:-
1. 在新活动中启动详细信息屏幕。
2. 使用 currentDestination 路由作为状态,有条件地隐藏详情屏幕路由的底部和应用栏。
两种方法都有效,但是第一种方法的问题是,不建议在喷气背包导航中使用多个活动,相反,我们应该坚持单个活动,如果我想从详细信息转移到详细信息,它也会进一步破坏导航。另一个屏幕。第二种方法的问题在于,隐藏和显示底部/顶部栏会在屏幕之间产生非常糟糕的过渡,并且应用程序感觉不流畅。
因此,我正在寻找一种适当的方法来按照指南处理此问题,尽管我找不到任何相关信息。
更新
我根据路线显示/隐藏底部和应用程序栏,结果发现我面临的糟糕且滞后的动画是因为我正在运行一个调试应用程序,以及一个带有minifyEnabled true(R8)的发布应用程序,过渡非常平滑和自然,正如我想要的那样。
事实证明,根据 Google 的官方撰写示例应用程序JetSnack,这是实现从底部栏屏幕到非底部栏屏幕导航的适当方法。感谢@vitidev在评论中指出这一点。
android android-bottomnav android-jetpack-compose jetpack-compose-navigation
我想在我现有的Android应用程序中使用底部导航栏,但问题是所有屏幕都是活动,是否可以加载活动而不隐藏底部导航栏.
示例: activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.v4.widget.NestedScrollView
        android:id="@+id/myScrollingContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <!-- Your loooooong scrolling content here. -->
    </android.support.v4.widget.NestedScrollView>
    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_gravity="bottom"
        app:bb_tabXmlResource="@xml/bottom_bar"
        app:bb_behavior="shy"/>
</android.support.design.widget.CoordinatorLayout>
这是我的基础活动,
MainActivity.java
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BottomBar bottomBar;
        bottomBar = (BottomBar) findViewById(R.id.bottomBar);
        bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelected(@IdRes int tabId) {
                if (tabId == R.id.matching) {
                    Log.i("matching","matching inside "+tabId);
                    Intent in=new Intent(getBaseContext(),Main2Activity.class);
                    startActivity(in);
                }else if (tabId == R.id.watchlist) …我为我的应用程序添加了底部导航视图,但我需要在活动之间而不是片段之间的底部导航视图,因此我已将此代码添加到Java以用于我的所有3个活动.
当我在手机中选择"秒"或"第三"时,所有内容都是正确的,但问题是突出显示第一项.
我需要突出显示我按下的项目.
我已经使用了片段,它工作得很好,但我仍然是使用片段的初学者所以我正在使用活动.
第一个活动代码是:
BottomNavigationView mBottomNavigation;
    mBottomNavigation =(BottomNavigationView) findViewById(R.id.BottomNavigator);
    mBottomNavigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()){
                case R.id.Nav_Second:
                    Intent Second= new Intent(First.this, Second.class);
                    startActivity(Second);
                    break;
                case R.id.Nav_Third:
                    Intent Third= new Intent(First.this, Third.class);
                    startActivity(Third);
                    break;
            }
            return true;
        }
    });
}}
第二项活动是:
BottomNavigationView mBottomNavigation;
    mBottomNavigation =(BottomNavigationView) findViewById(R.id.BottomNavigator);
    mBottomNavigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()){
                case R.id.Nav_First:
                    Intent First= new Intent(Second.this, First.class);
                    startActivity(First);
                    break;
                case R.id.Nav_Third:
                    Intent Third= new Intent(Second.this, Third.class); …java android android-navigation bottomnavigationview android-bottomnav
目前,我正在玩带有底部导航栏的 Android 导航组件。在玩的过程中,我意识到两个事实:
onCreate, onViewCreated,onViewDestroyed一旦用户导航到另一个片段就会被调用)savedInstanceState始终为空(在onCreate,onViewCreated等等)第一个问题可以通过使用 custom 修复,FragmentNavigator如果片段已经存在,它将重用
package am.chamich.apps.advancedbottomnavigation.navigator
import android.content.Context
import android.os.Bundle
import androidx.navigation.NavDestination
import androidx.navigation.NavOptions
import androidx.navigation.Navigator
import androidx.navigation.fragment.FragmentNavigator
@Navigator.Name("retain_state_fragment")
class RetainStateFragmentNavigator(
    private val context: Context,
    private val manager: androidx.fragment.app.FragmentManager,
    private val containerId: Int
) : FragmentNavigator(context, manager, containerId) {
    override fun navigate(
        destination: Destination,
        args: Bundle?,
        navOptions: NavOptions?,
        navigatorExtras: Navigator.Extras?
    ): NavDestination? {
        val tag = destination.id.toString()
        val transaction = manager.beginTransaction()
        val currentFragment …android android-fragments android-navigation android-bottomnav android-architecture-components
我在切换到底部导航的最后一个片段时遇到此错误,因此最后一个片段加载有点慢
E/FrameEvents: updateAcquireFence: Did not find frame. 2022-01-03 12:35:41.373 14186-15042/com.pandojo E/BufferQueueProducer: [ImageReader-329x48f1u256m2-14186-447](id:376a000001bf,api:0,p:-1,c:14186) disconnect: not connected (req=1) 2022-01-03 12:35:41.373 14186-15042/com.pandojo W/libEGL: EGLNativeWindowType 0x7b81c7d010 disconnect failed
android material-design bottomnavigationview android-bottomnav
现在我想知道哪种方法最适合BottomNavigation与新方法结合使用Android Architecture Navigation Component?
现在发现两种方法:
BottomNavigation项目,可从Google Codelabs以下网址显示:https : //codelabs.developers.google.com/codelabs/android-navigation/#1 BottomNavigation项目都有其自己的属性,navigation graph仅维护其行为backstack,我在此处显示了它:https : //proandroiddev.com/mastering-the-bottom-navigation-with-the-new-navigation-architecture-component-cd6a71b266ae我的观点是,第二种观点更加清晰和可以理解,但也许您有另一种观点。
android android-bottomnav android-bottom-nav-view android-architecture-components android-jetpack