0

How do I insert a scrollview into this, and still keep the header that I have on my app? Also, all of the tutorials seem to require you to switch to a LinearLayout, and the LinearLayout makes it hard for me to format all the buttons and text boxes that I need to include in the activity.

<?xml version="1.0" encoding="utf-8"?>
<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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="washingtondeli.groupboxlunchesestimateandordering.CapitolhillActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Capitol Hill Picnic Box Lunch"
        android:id="@+id/capitolhilltitle"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>
Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
Casey
  • 21
  • 1
  • 6
  • What seems to be the problem? Just wrap your TextView inside a scrollView. Also, get used to working with LinearLayouts, cause oftentimes they're much more consistent looking on different devices that RelativeLayouts. – Vucko Jun 08 '16 at 22:30
  • Look at this question: http://stackoverflow.com/questions/6674341/how-to-use-scrollview-in-android – KevinTheGreat Jun 08 '16 at 22:51

2 Answers2

3

Step 1: Make ScrollView your root layout

Step 2 Add a LinearLayout to your ScrollView

Remember, a ScrollView accepts only 1 Child

Then simply add your buttons inside your LinearLayout - which by the way could have other LinearLayouts to support different layout styles and then you have weights to position your items accordingly!

You can also look into other options. Oh, almost forgot this: read some tutorials on this to help you get started!

I hope this helps!

Eenvincible
  • 5,641
  • 2
  • 27
  • 46
  • thanks for the help. i am trying to add buttons now that i am in linear view, it is no longer letting me drag and drop things – Casey Jun 09 '16 at 00:40
0

You can use Relative Layout in a Scroll View, Here's a sample, for scroll view with relative layout with a fixed Header

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


    <TextView
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:text="Header"
        android:textColor="#ffffff"
        android:textSize="22dp" />

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_below="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="0dp"
        android:fillViewport="true" >

        <RelativeLayout
            android:id="@+id/filt_top"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:animateLayoutChanges="true" >

            //your scrollable contents here

        </RelativeLayout>

    </ScrollView>

    </RelativeLayout>
Karun Shrestha
  • 731
  • 7
  • 16