Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Fragment

How to make a Fragment Scrollable . The whole Fragment should be scrollable .

2 Answers

Try using a ScrollView. You can find more information here:

https://github.com/codepath/android_guides/wiki/Working-with-the-ScrollView

That is great , but i cant move the widgets as my wish even though i added Relative layout and Relative layout is not wrapping in Height

Can you describe your layout a bit more and post some code?

I added Navigation Drawer and for Home tab in Navigation Drawer , i added Fragment and i need that Fragment to scroll but when i scroll the toolbar is not Scrolling and the tidget/textview is overlapping / going to the toolbar. I need to scroll the toolbar or when i scroll the textview should go beneath the toolbar , how do i do that.

This is my XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.weebly.gnanicg.dailyremainder.MainFragment">

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


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:layout_alignParentTop="true">


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:baselineAligned="false"
        android:fillViewport="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1 AM"
            android:id="@+id/textView3"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="37dp"
            android:layout_marginStart="37dp"
            android:layout_marginTop="104dp" />
    </ScrollView>


</RelativeLayout>

</RelativeLayout>

I don't have an exact answer to your question but take a look at this page for examples of collapsing toolbars:

https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout#expanding-and-collapsing-toolbars

Thanks