Как сделать операцию с относительной компоновкой, Framelayout, NavigationBarLayout, прокручиваемую в Android Studio?

-6

Я хочу сделать свой прокрутки Activity Framelayout но только Framelayout. Я использую фрагменты, панель инструментов и BottomNavBar а FrameLayout находится между BottomNav и Toolbar.

главное меню

<?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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/MainGreen"
tools:context=".mainmenu">

<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />

/* --- main codes insert here --- */

<FrameLayout
android:id="@+id/main_frame"
android:layout_width="match_parent"
android:layout_height="454dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/toolbar"
android:layout_above="@+id/navigation">

</FrameLayout>

<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="@color/colorWhite"
app:elevation="16dp"
app:menu="@menu/navigation"
app:itemIconTint="@drawable/navigation_color_selector"
app:itemTextColor="@drawable/navigation_text_color_selector"/>
</RelativeLayout>

Выход

enter image description here

спросил(а) 2021-01-25T19:59:51+03:00 4 месяца, 3 недели назад
1
Решение
99

Этот исходный код содержит меню навигации с макетом ящика, макет кадра, который используется для загрузки меню фрагмента и нижней навигации, с помощью которого вы можете изменять фрагменты.

Вы можете следить за ним.

//activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:fitsSystemWindows="true">

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="@dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_above="@+id/rl_logout"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/menu_main_drawer" />

</RelativeLayout>

</android.support.v4.widget.DrawerLayout>

//app_bar_main.xml


 <?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"
android:fitsSystemWindows="true"
tools:context=".Activities.ActivityMain">

<android.support.design.widget.AppBarLayout
android:id="@+id/home_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<include layout="@layout/common_toolbar"/>

</android.support.design.widget.AppBarLayout>

</android.support.design.widget.AppBarLayout>

<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/navigation"
android:layout_below="@+id/home_app_bar"
app:layout_behavior="@string/appbar_scrolling_view_behavior"></FrameLayout>

<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="@color/colorPrimary"
android:foreground="?attr/selectableItemBackground"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/navigation" />

</RelativeLayout>

//nav_header_main.xml

<?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"
android:id="@+id/view_container"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:gravity="bottom"
android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin">

<ImageView
android:id="@+id/img_profile"
android:layout_width="wrap_content"
android:layout_height="@dimen/profile_height"
android:layout_gravity="center"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:src="@drawable/agreeta_logo" />

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:layout_gravity="center"
android:textColor="@color/colorPrimaryDark"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />

<TextView
android:id="@+id/website"
android:textColor="@color/light_black"
android:layout_width="wrap_content"
android:text="@string/website"
android:layout_gravity="center"
android:layout_height="wrap_content" />

</LinearLayout>

</RelativeLayout>

//menu_main_drawer.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<group android:checkableBehavior="single">
<item
android:id="@+id/nav_home"
android:icon="@drawable/home_icon"
android:title="@string/nav_home" />
</group>
<group android:checkableBehavior="single">
<item
android:title="Order History"
android:icon="@drawable/shopping_cart_green"
android:id="@+id/menu_order">

</item>
</group>

</menu>

ответил(а) 2021-01-25T19:59:51+03:00 4 месяца, 3 недели назад
45

Попробуйте это, я изменил ваш код, который вам нужен, только прокручиваемый FrameLayout

<?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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/MainGreen"
tools:context=".mainmenu">

<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />

/* --- main codes insert here --- */
/* fillViewport prperty added to show the full view in scroll*/
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
android:layout_above="@+id/navigation"
android:layout_alignParentStart="true"
android:fillViewport="true"
>
<FrameLayout
android:id="@+id/main_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"

>

</FrameLayout>
</ScrollView>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="@color/colorWhite"
app:elevation="16dp"
app:menu="@menu/navigation"
app:itemIconTint="@drawable/navigation_color_selector"
app:itemTextColor="@drawable/navigation_text_color_selector"/>
</RelativeLayout>

ответил(а) 2021-01-25T19:59:51+03:00 4 месяца, 3 недели назад
45

переместите рамку в прокрутку. Используйте этот фрагмент.

<?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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/MainGreen"
tools:context=".mainmenu">

<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/toolbar"
android:layout_above="@+id/navigation"
>
/* --- main codes insert here --- */

<FrameLayout
android:id="@+id/main_frame"
android:layout_width="match_parent"
android:layout_height="454dp">

</FrameLayout>

</ScrollView>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="@color/colorWhite"
app:elevation="16dp"
app:menu="@menu/navigation"
app:itemIconTint="@drawable/navigation_color_selector"
app:itemTextColor="@drawable/navigation_text_color_selector"/>
</RelativeLayout>

ответил(а) 2021-01-25T19:59:51+03:00 4 месяца, 3 недели назад
45

Использование scrollview - это root, который помещает все ваши макеты внутри прокрутки

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<!-- your code -->

</RelativeLayout>
</ScrollView>

ответил(а) 2021-01-25T19:59:51+03:00 4 месяца, 3 недели назад
Ваш ответ
Введите минимум 50 символов
Чтобы , пожалуйста,
Выберите тему жалобы:

Другая проблема