底部导航视图隐藏的滚动视图最后的底部内容

时间:2021-01-23 15:52:44

标签: java xml android-layout kotlin

嗨编码员我有一个约束布局,它是一个底部导航视图 顶部的工具栏和滚动视图,其中有许多垂直向下的按钮。 问题是滚动视图的最后一个按钮在我一直滚动到底部后隐藏在底部导航视图后面如何解决 在实际代码中,滚动视图中有很多按钮,我在这里只添加了几个。

<android.support.constraint.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:id="@+id/container"
    android:background="#ffffff"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
<include 
    android:id="@+id/tutorialsinclude"
    layout="@layout/app_bar_main"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    
    />
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toBottomOf="@id/tutorialsinclude"
    android:id="@+id/webtut">

    <LinearLayout
        
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/activity_horizontal_margin"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:orientation="vertical"
        >
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="web "
            android:id="@+id/tutorialsButton1"/>
        
            <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Tutorials 1 "
            android:id="@+id/tutorialsButton1"/>
    </LinearLayout>
</ScrollView>
      <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigationbb"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="0dp"
        android:layout_marginEnd="0dp"
        android:background="#ffffff"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>

As you can see in this image the last button is hidden by the bottom navigation view and I can't scroll further up to reveal the button

2 个答案:

答案 0 :(得分:1)

您可以在最后放置一个页脚来解决此问题。只需在最后一个按钮下方创建一个 View。像这样:

 <View android:layout_width="match_parent"
       android:layout_height="32dp" />

您只需调整高度即可使其适合您的布局。此外,您真的不应该手动将所有这些按钮放在 scrollView 中。应该改用 RecyclerView

答案 1 :(得分:1)

将滚动视图底部的约束设置为底部导航视图的顶部,并将高度设置为 0dp,这将使高度与约束匹配

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layout_constraintTop_toBottomOf="@id/tutorialsinclude"

    app:layout_constraintBottom_toTopOf="@id/navigationbb"

    android:id="@+id/webtut">