Android BottomNavigationBar usando ConstraintLayout y ScrollView

Zatosasa:

Estoy creando una aplicación sencilla para la visualización de las listas de música y podcasts en posición horizontal, en la parte inferior de la pantalla que quiero siempre BottomNavigationBar visible. Pero sin la adición de un margen explícito sobre ScrollView, el texto de mi podcast_list se oculta, se siente como un truco, ¿hay un bonito y más limpio manera cómo lograr mismo resultado?

Aquí está mi código XML:

<?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"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="64dp"> <---- HACK ?

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:context=".MainActivity">

            <TextView
                android:id="@+id/podcast_category"
                style="@style/categories"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/podcasts_category_text"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@id/parent" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/podcast_list"
                style="@style/media_list"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@id/podcast_category" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </ScrollView>

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
        app:layout_constraintTop_toTopOf="parent" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/bottom_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
droidbaza:

en lugar androide: layout_marginBottom = "64DP" sólo tiene que añadir androide: paddingBottom = "? attr / actionBarSize"

Supongo que te gusta

Origin http://10.200.1.11:23101/article/api/json?id=389777&siteId=1
Recomendado
Clasificación