Zatosasa:
Ich erstelle eine einfache Anwendung zur Anzeige von Musik & Podcast Listen horizontal, am unteren Rand des Bildschirms will ich immer sichtbar BottomNavigationBar. Aber ohne Zugabe eine explizite Marge auf Scrollview, wird der Text meines podcast_list versteckt, es fühlt sich an wie ein Hack, ist es eine schöne und saubere Weise, wie gleiches Ergebnis zu erzielen?
Hier ist mein XML-Code:
<?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:
Statt android: layout_marginBottom = "64dp" just android hinzufügen: paddingBottom = "attr / actionBarSize"