bottomnavigationview 相关问题

与底部导航栏相关的问题。底部导航栏菜单项标题,图标,填充内容和启用状态相关问题。底部导航栏项目单击侦听器,项目背景资源,项目文本颜色,膨胀菜单,最大项目计数。底部导航栏是材料设计底部导航的实现。

像 Instagram 一样的底部屏幕导航

你好,我正在尝试实现底部屏幕导航,就像 Flutter 中的 Instagram 一样。 我尝试过标签栏、底部栏,但我无法实现。 我也在 GitHub 和 google 上搜索过,但没有……

回答 1 投票 0

有没有办法将FloatingActionButton保持在固定位置(打开BottomSheet)?

我正在开发一个flutter应用程序,它有一个页面,其中有一个(圆形凹口矩形)BottomAppBar、一个FloatingActionButton和一个BottomSheet,当用户单击标记时会出现......

回答 1 投票 0

如何实现 BottomNavigationView 的选项卡选择器?

你好, 我只想为 BottomNavigation 视图实现一个选项卡选择器,如下所示: 目前我不关心项目动画,我只想放置底部矩形以供选择...

回答 1 投票 0

如何将屏幕更改为带有kivymd底部导航的屏幕

我将 KivyMD BottomNavigation 添加到我的应用程序中,我可以使用图标切换屏幕,但问题是切换回包含 BottomNavigation 的屏幕 (假设我们在任何屏幕中

回答 2 投票 0

Kotlin:setOnNavigationItemSelectedListener 中出现错误“将 lambda 表达式返回类型更改为 Unit”

我正在 Kotlin 中开发一个应用程序,并使用 BottomNavigationView 通过 ViewPager 在不同片段之间导航。我正在尝试将 setOnNavigationItemSelectedListener 方法实现为

回答 1 投票 0

在真实设备中将导航模式更改为底部导航后,按钮导航栏高度异常

我正在开发Android项目。在手势模式下显示完美当我在设备中启用手势导航时,按钮导航栏显示完美,但当我切换ba时,它的高度变得太大...

回答 1 投票 0

如何在Android中从BottomNavigationView中删除多余的白色背景?

<?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/lt_content" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black" android:fitsSystemWindows="true"> <com.google.android.material.bottomappbar.BottomAppBar android:id="@+id/bottom_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:clickable="false" app:fabAlignmentMode="center" /> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom"> <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_parent" android:background="@android:color/transparent" android:layout_height="wrap_content" android:clickable="false" app:menu="@menu/bottom_nav_menu" /> </FrameLayout> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_anchor="@id/bottom_bar" /> </androidx.coordinatorlayout.widget.CoordinatorLayout> 我目前正在开发一个 Android 项目,我在 BottomAppBar 中实现了 BottomNavigationView。但是,我遇到了一个问题,即 BottomNavigationView 中的图标标签周围有额外的白色背景,我无法将其删除。 在此处查看输出 看这里 Vishvambhar 首先你必须找到那个白色背景来自哪里。正如我所看到的 FrameLayout 没有任何背景,因此将其更改为透明并添加 BottomAppBar 的高度将解决您的问题。 试试这个: <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/lt_content" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black" android:fitsSystemWindows="true"> <com.google.android.material.bottomappbar.BottomAppBar android:id="@+id/bottom_bar" android:layout_width="match_parent" android:layout_height="@dimen/_40sdp" android:layout_gravity="bottom" android:clickable="false" app:fabAlignmentMode="center" /> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:layout_gravity="bottom"> <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:clickable="false" app:menu="@menu/bottom_nav_menu" /> </FrameLayout> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_anchor="@id/bottom_bar" /> </androidx.coordinatorlayout.widget.CoordinatorLayout>

回答 1 投票 0

无法隐藏/显示滚动底部导航视图(片段 - >活动)

我尝试为底部导航视图添加隐藏/显示行为,但它不起作用 我指的是这个答案 根据该答案,我添加了应用程序:layout_behavior =“com.google.android.material。

回答 1 投票 0

如何占用BottomNavigationView之后剩余的空闲空间

activiti xml 文件: activiti xml 文件: <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="JavaClassForActivity.Profile" android:id="@+id/ProfileLayout" android:background="@drawable/main_back_ground"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/profileFrameLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_constraintBottom_toTopOf="@id/bottomNavigation" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> </FrameLayout> <androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/mainCoordinatorLayout" android:layout_width="match_parent" android:layout_height="0dp" app:layout_constraintBottom_toTopOf="@id/bottomNavigation" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"> <include android:id="@+id/bottom_sheet_parent" layout="@layout/bottom_sheet_music" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" /> </androidx.coordinatorlayout.widget.CoordinatorLayout> <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottomNavigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" app:menu="@menu/bottom_nav_menu" android:background="@color/teal_700" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"/> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout> Java代码: public class Profile extends AppCompatActivity{ BottomNavigationView bottomnavigation; private BottomSheetBehavior<View> bottomSheetBehavior; private LinearLayout layoutTop, layoutExpanded; int peekHeight; private View bottomSheet; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_your_profile); bottomSheet = findViewById(R.id.bottom_sheet_parent); bottomnavigation=findViewById(R.id.bottomNavigation); View bottomSheet = findViewById(R.id.bottom_sheet_parent); bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); layoutTop = findViewById(R.id.layout_top); layoutExpanded = findViewById(R.id.layout_expanded); // Setup the bottom sheet with initial peek height and behavior settings setupBottomSheet(); // Set initial state bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } private void setupBottomSheet() { ViewTreeObserver vto = layoutTop.getViewTreeObserver(); vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { layoutTop.getViewTreeObserver().removeOnPreDrawListener(this); peekHeight = layoutTop.getHeight(); bottomSheetBehavior.setPeekHeight(peekHeight); bottomSheetBehavior.setHideable(false); bottomSheetBehavior.setFitToContents(true); return true; } }); bottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { @Override public void onStateChanged(@NonNull View bottomSheet, int newState) { handleBottomSheetState(newState); } @Override public void onSlide(@NonNull View bottomSheet, float slideOffset) { handleSlideOffset(slideOffset); } }); } private void handleBottomSheetState(int newState) { if (newState == BottomSheetBehavior.STATE_EXPANDED) { layoutTop.setVisibility(View.GONE); layoutExpanded.setVisibility(View.VISIBLE); } else if (newState == BottomSheetBehavior.STATE_COLLAPSED) { layoutTop.setVisibility(View.VISIBLE); layoutExpanded.setVisibility(View.GONE); } else if (newState == BottomSheetBehavior.STATE_HALF_EXPANDED) { layoutTop.setVisibility(View.GONE); layoutExpanded.setVisibility(View.VISIBLE); // Only set state to expanded if necessary if (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) { bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); } } } private void handleSlideOffset(float slideOffset) { float topAlpha = 1 - slideOffset; float expandedAlpha = slideOffset; layoutTop.setAlpha(topAlpha); layoutExpanded.setAlpha(expandedAlpha); if (layoutTop.getVisibility() == View.VISIBLE && !layoutTop.isActivated()) { layoutExpanded.setVisibility(View.VISIBLE); } else if (layoutExpanded.getVisibility() == View.VISIBLE && !layoutExpanded.isActivated()) { layoutTop.setVisibility(View.VISIBLE); } bottomnavigation.setTranslationY(bottomnavigation.getHeight() * slideOffset); ViewGroup.LayoutParams params = bottomSheet.getLayoutParams(); params.height = bottomSheet.getHeight() + (int) (bottomnavigation.getHeight() * slideOffset); bottomSheet.setLayoutParams(params); } } bottom_sheet_music xml 文件: ` </LinearLayout> <!-- layout_expanded --> <LinearLayout android:id="@+id/layout_expanded" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:visibility="gone" android:background="@color/black"> </LinearLayout> 我不知道如何解决这个问题,如果你能给我一个如何解决这个问题的例子,我将不胜感激。 我尝试了发现的不同选项,但无法解决问题。任何帮助将不胜感激。 我遇到了同样的问题,但对我来说,在 BottomNavigation 后面使用一些具有所需颜色的图层解决了它

回答 1 投票 0

从片段导航时底部导航栏出现故障

我将底部导航栏与导航组件一起使用 为了使这两个组件协同工作,我调用了: 底部NavigationView.setupWithNavController(navController) 一切正常

回答 3 投票 0

无法更改底部导航图标色调

我试图对底部导航实施图标色调,但由于某种原因似乎不起作用, 我添加了硬编码的#color代码,并将其添加到colors.xml中,并为此创建了一个选择器

回答 1 投票 0

将 BottomNavigation 与列表相结合 - Jetpack compose 中带有动画的详细导航

给定一个带有一些底部栏按钮和部分的典型应用程序,用户可以在其中从列表导航到详细信息,理想情况下,我希望为底部栏过渡保留良好的默认淡入淡出效果,并且...

回答 1 投票 0

如何更改 Kotlin 中 android studio 底部导航栏中所选项目周围的颜色?

我找不到更改底部导航栏中所选项目周围颜色的方法。就像下图中的紫色一样。 我尝试更改原色(

回答 2 投票 0

Android 底部导航视图占用太多高度

我没有使用任何样式/主题或任何复杂的自定义,但底部导航视图占据了意想不到的高度, 我使用 wrap_content 作为高度,因此得到以下输出: 我没有使用任何样式/主题或任何复杂的自定义,但底部导航视图正在采取意外的高度, 我使用 wrap_content 作为高度,因此得到以下输出: <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_nav" android:layout_width="match_parent" **android:layout_height="wrap_content"** app:labelVisibilityMode="selected" app:menu="@menu/bottom_nav_menu" /> 当使用固定高度时,即?attr/actionbarsize我得到以下输出(所有图标/标签折叠): 代码: <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_nav" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:labelVisibilityMode="selected" app:menu="@menu/bottom_nav_menu" /> 布局完整代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".AppInstalledCheckActivity" android:background="#FFEB3B"> <EditText android:id="@+id/edittextPackageName" android:layout_width="match_parent" android:layout_height="60dp" android:hint="Enter Package Name" /> <Button android:id="@+id/buttonCheckInstalled" android:layout_width="match_parent" android:layout_height="45dp" android:text="Enter Package Name" /> <androidx.fragment.app.FragmentContainerView android:id="@+id/nav_host_fragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="400dp" app:navGraph="@navigation/navgraph" /> <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_nav" android:layout_width="match_parent" android:layout_height="wrap_content" app:labelVisibilityMode="selected" app:menu="@menu/bottom_nav_menu" /> </LinearLayout> 我希望它与工具/操作栏具有相同或相似的高度。 你需要改变 <androidx.fragment.app.FragmentContainerView android:id="@+id/nav_host_fragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" **android:layout_height="400dp"** app:navGraph="@navigation/navgraph" /> 到 **android:layout_height="match_parent"**

回答 1 投票 0

(BottomNavigationView) 此组件上的样式要求您的应用程序主题为 Theme.AppCompat (或后代)

在我的应用程序布局中使用 com.google.android.material.bottomnavigation.BottomNavigationView 时,出现以下错误: 引起原因:android.view.InflateException:com.e 中的二进制 XML 文件第 25 行...

回答 1 投票 0

为什么我的底部导航栏下方有一个空格?

底部导航图标下方有一个很大的空间。我想解决它很长时间但无法解决。 这是标记: 底部导航图标下方有一个很大的空间。我尝试了很长时间但无法解决。 这是标记: <FrameLayout android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> </FrameLayout> <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottomNavigationView" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:menu="@menu/bottom_nav_menu" /> 我想解决它。 从 java 活动中删除此代码解决了我的问题 ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); return insets; });

回答 1 投票 0

Flutter 中的某些设备中底部导航栏需要更高的高度

我正在 Flutter 应用程序中开发 BottomNavigationBar,但我注意到,它在某些手机中需要更高的高度,例如某些 Iphone、三星 Galaxy S23 等。 我尝试将 Container 或 SizeBox 与 pre-

回答 1 投票 0

Flutter 中 BottomAppBar 的异常行为

我遇到了 FloatingActionButton 和 BottomAppBar 在此处输入图像描述的异常行为, 我面临的问题是凹口不在中心,而且行的槽...

回答 1 投票 0

底部导航如何从片段内部更改片段

我有一个包含 3 个片段的底部导航视图 我想从片段 1 内部而不是从活动中将片段 1 更改为片段 2 有谁知道怎么做吗?

回答 2 投票 0

如何让底部导航Activity通过滑动改变片段?

我使用适当的 android studio 模板创建了一个新活动:新建->活动->底部导航活动。我向 AppBarConfiguration 添加了 5 个片段,除了一个之外一切正常......

回答 2 投票 0

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