1
直接切入追踪。我想为我的应用程序有一个底部导航栏,然后在顶部有一个工具栏,中间是将放置内容的滚动视图。底部导航栏通过滚动视图布局被推出视图
现在的问题是,ScrollView布局将导航栏推出视图,现在导航栏不会显示。
另一种解决方法我试过,但事实证明,在导航栏上的滚动型
That blue bar below the Home toolbar is the navigation bar.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="polytechnic.temasek.bluebeatsmusicapplication.HomePageActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@drawable/bluebeatsbackground2">
<TextView
android:id="@+id/toolbartitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Home"
android:textColor="@android:color/white"
android:textSize="32sp"
android:textStyle="bold" />
</android.support.v7.widget.Toolbar>
<ScrollView
android:layout_width="match_parent"
android:layout_height="539dp"
>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="0dp">
[Content inside]
</android.support.constraint.ConstraintLayout>
</ScrollView>
<android.support.design.widget.BottomNavigationView
android:id="@+id/the_bottom_navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="@color/colorPrimary"
app:itemBackground="@color/colorPrimary">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
顶部弹出到目前为止,我只能够将滚动视图的高度暴力强制为某个特定的dp,以便为导航栏腾出空间,但是必须有另一种我应该丢失的方式?
你好,这个解决方案工作得很好,但我想知道为什么你使用的LinearLayout来约束或相对变化? – MechaKondor
[约束布局](https://developer.android.com/training/constraint-layout/index.html)与其他布局相比具有许多优势:*更好地控制您的视图。 *较少嵌套布局。 *少写代码。 (大部分工作都可以在Layout编辑器中完成。)以及更多...只需浏览一些教程,您一定会发现它更容易(看起来很复杂;))。接受答案,如果它的工作; P –