Как поместить скроллвью в этот макет, не конфликтуя с нижней навигацией?
Я так много пытался, и я не могу заставить это работать.. Как мне создать этот макет так, чтобы я мог иметь вид прокрутки между панелью приложения и нижней навигацией, не перемещая нижнюю навигацию под представлением или имея часть scrollview скрытый за панелью приложения или нижней навигацией?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/white_grey_border_bottom">
<TextView
android:id="@+id/appBarLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Lost & Found"
android:textColor="@color/colorBlack"
android:textSize="30dp"
android:textStyle="bold" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottomNavView_Bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:background="@drawable/white_grey_border_top"
app:menu="@menu/bottom_navigation_menu">
</android.support.design.widget.BottomNavigationView>
</RelativeLayout>
2 ответа
Решение
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_root"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!-- Add your AppBarLayout and ScrollView here, inside the CoordinatorLayout -->
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Это мой макет:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".KalenderActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/white_grey_border_bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="15dp"
android:orientation="horizontal"
android:weightSum="2">
<TextView
android:id="@+id/appBarLabel1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Andels "
android:textAlignment="textEnd"
android:textColor="@color/colorBlack"
android:textSize="30dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/appBarLabel2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:text="App "
android:textColor="@color/colorWhite"
android:textSize="30dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ListView
android:id="@+id/lvKalenderEvents"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottomNavView_Bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/white_grey_border_top"
app:menu="@menu/bottom_navigation_menu">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
Вылетает при попытке открыть активность в приложении...