asked    Olive     2018-10-22       android       105 view        4 Answers

[SOLVED] How Do I make an Activity with a Relative Layout, a Framelayout, NavigationBarLayout, scrollable in Android Studio?

I want to make my Activity scroll able but only the Framelayout. I'm using fragments, a Toolbar and a BottomNavBar and the FrameLayout is between the BottomNav and the Toolbar.

main menu

<?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>

Output

enter image description here

  4 Answers  

        answered    Darlene     2018-10-22      

Try this, I have modified your code you want only FrameLayout scrollable

<?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>


        answered    Maxwell     2018-10-22      

Use scrollview is root put all your layout inside the scroll view

<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>


        answered    Lydia     2018-10-22      

put your framelayout inside the scroll view. Use this snippet.

<?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>


        answered    Frederic     2018-10-22      

This source code contains navigation menu with drawer layout , frame layout which is used to load fragment and bottom navigation menu by which you can change fragments.

You can follow it.

//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="" />

        <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>




Your Answer





 2018-10-22         Daniel

how to make a html login page that connect to database

Lets say I have a login.html page with a html templateAnd I want to use that login.html template to login to another login.php page.Say, when a user types in email and password in login.html, I want that login.html page to type the same email and password in my another website which has login.php page.For this example, lets take blesta - it has a login.php page but the landing page is simple and is not beautiful.I have another html page named login.html which looks sleek and beautiful but I don't want to transfer users to blesta login.php and then they enter their credentia...
 html                     1 answers                     85 view
 2018-10-22         Maurice

python ~ requests // login and send form not working

Ive written code for a programming mission 2 on hackthissite, just some fun and to practice coding etc. I have completed the mission but i was unable to get python to login using the requests library and upload my code to the form automatically.Here is a snippet from my code with the code that is not working and still says 'you need to login' etc, when page content.def upload_code(key): login_url = 'https://www.hackthissite.org/user/login'btn_submit = 'Login'username = 'example_username'password = 'example_password''login = { 'btn_submit':btn_submit, 'passw...
 python                     1 answers                     86 view
 2018-10-22         Tobey

Flutter padding between border and widget

I'm trying to use Flutter to create a card widget with an icon and a title. But i'm not able to add some margin between border of the cards and the widget.Here's my card code:class MyCard extends StatelessWidget{ MyCard({this.title, this.icon}); final Widget title; final Widget icon; @override Widget build(BuildContext context) { return new Container( padding: EdgeInsets.only(bottom: 20.0), child: new Card( child: new Row( children: <Widget>[ this.icon, new Container( width: 20.0, //I also don't know if this is lega...
 flutter                     2 answers                     84 view