我试图让BottomSheetDialogFragment 出现在BottomNavigationView 的顶部和BottomNavigationView 下方,即具有较低的高度。BottomSheetDialogFragment 将具有一个类似 YouTube 的视频播放器,带有一个 RecyclerView 并可以展开和折叠底部表。我已经研究了几个建议,但没有解决。包括 Stackoverflow。我按照下面的代码尝试了 Show () 方法的两种变体 - 但都没有奏效。我可以做展开、折叠等动作,不用担心。问题是将BottomSheet放在BottomNavigationView后面和Activity的RecyclerView上面。
公共类 myController 扩展了 CommonActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//inflate the layout of the activity
setContentView(R.layout.controller_layout);
//other activity codes
//progressBar = findViewById(R.id.progressBar);
//contains initialization codes for views and recyclerview
//initViews();
}
OPTION 01: It's the CALL that everyone is pointing to BottomSheetDilogFragment, except BottomSheet is over BottomNavigationView
INITIALIZED when clicking on a item (thumbnail) of a RecyclerView in the layout of …Run Code Online (Sandbox Code Playgroud) 我想BottomAppBar用圆角、圆形缺口矩形和材质阴影创建。问题是,当我BottomAppBar通过用ClipRRect小部件包裹圆角来添加圆角时,我会丢失材质阴影。
BottomAppBar 没有圆角,但带有 Material 阴影。请忽略错误对齐的缺口。

BottomAppBar 包裹在 ClipRRect 小部件中,但没有阴影。再次请忽略错误对齐的缺口:

如何用缺口和材质阴影实现圆角?
完整代码:
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: Scaffold(
extendBody: true,
body: Container(
color: Colors.amber,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: Transform.translate(
offset: Offset(0, -10),
child: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
elevation: 2.0,
),
),
bottomNavigationBar: BottomNavigationView(),
),
);
}
}
class BottomNavigationView extends StatelessWidget {
@override
Widget build(BuildContext context) …Run Code Online (Sandbox Code Playgroud) rounded-corners flutter bottomnavigationview flutter-layout bottomappbar
我想用页面浏览量构建底部导航栏。它将是 3 页,您可以向左或向右过渡。我可以滑动,但我的导航栏选择的项目颜色不会改变。你能帮助我吗?
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _selectedIndex = 0;
final PageController _pageController = PageController();
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(
icon: Icon(Icons.portrait), title: Text('Profile')),
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('Home')),
BottomNavigationBarItem(
icon: Icon(Icons.shopping_cart), title: Text('Shop'))
],
onTap: _onTappedBar,
selectedItemColor: Colors.orange,
currentIndex: _selectedIndex,
),
body: PageView(
controller: _pageController,
children: <Widget>[
ProfilePage(),
HomeTables(),
ShoppingPage(),
],
),
);
}
void _onTappedBar(int value) {
setState(() { …Run Code Online (Sandbox Code Playgroud) 我有一个Activity应用程序。我创建了一个Navigation graph包含所有可能目的地的单个(Fragment )。
唯一Activity layout包含一个<fragment/>容器,因为它应该是。
有一个主要片段包含BottomNavigationView用户可以导航到所有重要目的地(其中 3 个)的位置。
当我按照BottomNavigationView官方文档中的许多教程或事件中所述实现 时,它会替换Activity. 因此,BottomNavigationView不再显示 ,因为它包含在 a 中Fragment而不是 中Activity。我想让它向右膨胀layout我希望它能够使主片段中的
我应该使用另一个Navigation graph特定于主片段的吗?我应该使用经典Listener(但我会失去使用经典的所有兴趣Navigation graph)?有我不知道的解决方案吗?
我该如何实施?我尝试创建两个不同的Navigation graph,但无法将其设置为我的BottomNavigationView
android bottomnavigationview android-architecture-navigation android-navigation-graph
如何设置材质组件margin的徽章?bottomNavigation
或者
padding当我们单击某个项目时,我们如何防止出现bottomNavigationView这样的情况,因为正如我们在这些图片中看到的那样,一些徽章会被隐藏。
当第 1 项为unSelected:
当第1项时isSelected(会隐藏一点徽章高度):
android android-layout kotlin bottomnavigationview material-components-android
我通过选择 \xe2\x80\x9cBottom Navigation Activity\xe2\x80\x9d 创建了新的 Android 项目。没有其他改变。仅修改\n\xe2\x80\x9cfragment_notifications.xml\xe2\x80\x9d 通过添加背景属性将背景设置为黑色。
\n
我的问题是:
\n感谢您提前抽出时间。
\n我正在使用 Android Studio 4.1.1 并在 AVD Nexus 6 API 26 上运行代码,下面是相关文件的源代码。除通知片段的背景外,全部由 Android Studio 生成。
\n活动_main.xml:
\n<?xml version="1.0" encoding="utf-8"?>\n<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"\n xmlns:app="http://schemas.android.com/apk/res-auto"\n android:id="@+id/container"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n android:paddingTop="?attr/actionBarSize">\n\n<com.google.android.material.bottomnavigation.BottomNavigationView\n android:id="@+id/nav_view"\n android:layout_width="0dp"\n android:layout_height="wrap_content"\n android:layout_marginStart="0dp"\n android:layout_marginEnd="0dp"\n android:background="?android:attr/windowBackground"\n app:layout_constraintBottom_toBottomOf="parent"\n app:layout_constraintLeft_toLeftOf="parent"\n app:layout_constraintRight_toRightOf="parent"\n app:menu="@menu/bottom_nav_menu" />\n\n<fragment\n android:id="@+id/nav_host_fragment"\n android:name="androidx.navigation.fragment.NavHostFragment"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n app:defaultNavHost="true"\n app:layout_constraintBottom_toTopOf="@id/nav_view"\n app:layout_constraintLeft_toLeftOf="parent"\n app:layout_constraintRight_toRightOf="parent"\n app:layout_constraintTop_toTopOf="parent"\n app:navGraph="@navigation/mobile_navigation" />\n\n</androidx.constraintlayout.widget.ConstraintLayout>\nRun Code Online (Sandbox Code Playgroud)\nmobile_navigation.xml如下:
\n<?xml version="1.0" encoding="utf-8"?>\n<navigation xmlns:android="http://schemas.android.com/apk/res/android"\n xmlns:app="http://schemas.android.com/apk/res-auto"\n xmlns:tools="http://schemas.android.com/tools"\n android:id="@+id/mobile_navigation"\n …Run Code Online (Sandbox Code Playgroud) 升级依赖后:
'com.google.android.material:material:xxx'
从1.4.0到1.5.0,导航项文本以某种方式从锚定在图标下方更改为图标上方:
从:
到:
这是一个功能还是一个错误,有修复吗?
我有一个非常简单的应用程序,由三个片段和一个底部导航栏组成,是通过使用 Android Studio 中的“新项目 -> 底部导航活动”创建的。第一个片段包含一个按钮,它应该将我带到第二个片段,就像单击底部导航栏的中间按钮一样。

有没有一个“标准”的方法来做到这一点?
我努力了:
launch(...)导航组件,该组件似乎使用自己的后堆栈启动片段并破坏底部导航。setSelectedItemId(...),这要么导致异常,要么以不同的方式破坏底部导航。android bottomnavigationview android-bottomnav android-architecture-navigation
我将导航库从2.3.5更新到2.4.2。更新后我开始收到此错误:java.lang.IllegalArgumentException: No destination with ID XXX is on the NavController's back stack. The current destination is null。执行以下步骤后会发生错误:FirstFragment -> SecondFragment [with another BottomNavigationView] -> ThirdFragment -> SecondFragment [crash]
我将尝试描述我正在做的事情:
我有两个片段BottomNavigationView。
class MainBottomNavFragment : Fragment() {
private lateinit var navController: NavController
override fun onStart() {
super.onStart()
if (!::navController.isInitialized) {
navController =
Navigation.findNavController(requireActivity(), R.id.mainBottomNavHostFragment)
}
binding.bottomNavigation.setupWithNavController(navController)
}
}
Run Code Online (Sandbox Code Playgroud)
布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
<fragment
android:id="@+id/mainBottomNavHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="false" …Run Code Online (Sandbox Code Playgroud) 由于右下角的曲线,我想将脚手架主体延伸到 AppBar 后面:
我试过Modifier.offset(y = (-25).dp)。它工作正常,但 BG 图像不再填充底部导航栏后面的区域:
Scaffold( topBar = { ... }, )
{ padding ->
Box(
Modifier.padding(padding),
contentAlignment = Alignment.TopCenter
) {
Box(
modifier = Modifier
.fillMaxSize()
.offset(y = (-25).dp), // BG image behind AppBar
) {
Image(
modifier = Modifier.fillMaxSize(),
painter = painterResource(R.drawable.bg),
contentDescription = null,
contentScale = ContentScale.FillBounds
)
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能两者兼得?
android ×7
android-architecture-navigation ×2
flutter ×2
appbar ×1
bottom-sheet ×1
bottomappbar ×1
kotlin ×1
material-components-android ×1
mobile ×1
offset ×1