Моята цел е да поставите "долен лист" на върха на a BottomNavigationView
като този:
Но той остава по следния начин. И двата изгледа се свиват:
Това е xml на моята основна дейност:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
android:background="@drawable/tierrota"
tools:context="com.example.juanjose.myapplication.ViajesActivity">
<!-- include main content -->
<include layout="@layout/bottomsheet" />
<!-- include bottom sheet -->
<include layout="@layout/bottom_navigation" />
</android.support.design.widget.CoordinatorLayout>
Код на bottom_navigation
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorClarito"
app:itemIconTint="@drawable/nav_item_color_state"
app:itemTextColor="@drawable/nav_item_color_state"
app:menu="@menu/bottom_navigation_main" />
</RelativeLayout>
И код на долния лист
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="80dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<TextView
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@color/colorBackgroundSemi"
android:gravity="center"
android:text="Bandeja de entrada"
android:fontFamily="@font/eraslght"
android:textColor="@color/colorLetra"
app:layout_anchor="@+id/bottom_navigation"
app:layout_anchorGravity="top"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="coisa2"
android:textColor="@android:color/white" />
</LinearLayout>
Аз съм нов с тези два елемента. Има ли някой, който знае как да постигне това, което търся?
Искам моят "долен лист" да действа като такъв и може да се разшири. Крайната ми цел е да добавим RecyclerView
вътре в BottomSheet
.
Отговори:
1 за отговор № 1Доколкото съм разбрал въпроса ви, вие искате RecyclerView
да се показва в долния ви лист. Това прави проблема много по-лесно. Нека ви кажа как.
Трябва да имате определена височина за навигацията си отдолу.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorClarito"
app:itemIconTint="@drawable/nav_item_color_state"
app:itemTextColor="@drawable/nav_item_color_state"
app:menu="@menu/bottom_navigation_main" />
</RelativeLayout>
Сега в долния си лист конфигурирайте RecyclerView
с clipToPadding
атрибут в него. Което ще има подложка в долната част на твоя RecyclerView
, Идеята е да няма нищо в обхванатия район на RecyclerView
който излиза с долния лист.
Ето как трябва да декларирате вашето RecyclerView
в долния си лист.
<android.support.v7.widget.RecyclerView
android:id="@+id/my_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="80dp" />
Имайте предвид, че зададох paddingBottom
точно до 80dp
което е височината на навигационния изглед.
Надявам се това да помогне.
2 за отговор № 2
Опаковайте двата елемента в линейно оформление. Не съм сигурен как се държи координаторното оформление, но мисля, че няма да ви позволи да "поръчвате" елементи (подобно на оформлението на рамката).