【发布时间】:2020-11-23 14:41:16
【问题描述】:
我正在一个带有动态模块的项目中工作。我们在仪表板模块中的导航栏。但我在另一个模块中工作,该视图是与仪表板活动相关的片段。我想显示一个快餐栏,但我的问题是导航栏中显示的是快餐栏而不是显示在片段视图的底部(我附上了照片)。我尝试了几件事,但我不知道如何解决。
这就是我创建小吃店的方式:
Snackbar.make(it, "test", Snackbar.LENGTH_INDEFINITE).show()
这是我的片段布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textAlignment="center"
android:text="Welcome"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
【问题讨论】:
-
在
BottomNavigationBar上方创建一个空白CoordinatorLayout,将其height至少设为100dp,并将此布局作为parentLayout传递给SnackBar。肯定会奏效。示例答案here.
标签: java android android-layout kotlin