0

Having a bit of an issue attempting to get some buttons to appear beneath a srcollview in an app that I'm putting together.

The bottom LinearLayout with the buttons doesn't appear on screen at all, it will no doubt be something obvious but I'm stumped at the moment. I thought that by using the RelativeLayout as the parent for the main page and then using the android:layout_below attribute I would be able to position them fairly easily?

<?xml version="1.0" encoding="utf-8"?>
 <!-- ViewFlipper -->
        <ViewFlipper
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/ViewFlipper01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >
<!-- Page 1 (Splash) -->
     <LinearLayout
          android:id="@+id/splashPage"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical" >
           <TextView
           android:id="@+id/splash"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" 
           android:text="Display Splash Image"/>
     </LinearLayout>
<!-- Page 2 (Main) -->
    <RelativeLayout
        android:id="@+id/mainPage"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
        <LinearLayout
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:layout_below="@+id/mainPage"
        >
                <TextView
               android:id="@+id/date"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" 
               android:gravity="center_horizontal" />
        </LinearLayout>
        <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:layout_below="@+id/header"
        >
              <TableLayout
               android:id="@+id/tableHolder"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" >
                    <!-- Dynamic TextViews Will Go In Here -->
              </TableLayout>
        </ScrollView>
        <LinearLayout
        android:id="@+id/buttonHolder"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_below="@+id/scrollView" 
        >
          <Button
           android:id="@+id/previous"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Previous" />
          <Button
           android:id="@+id/next"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Next" />
        </LinearLayout>
    </RelativeLayout>   
 </ViewFlipper> 
 <!-- End of ViewFlipper -->
cosmicsafari
  • 3,949
  • 11
  • 37
  • 56

2 Answers2

0

Add android:layout_alignParentBottom="true" to the bottom LinearLayout. It could be that your scroll view is consuming all available space.

Todd Sjolander
  • 1,459
  • 1
  • 15
  • 28
  • That makes them appear, but there floating on top of the scrollview content – cosmicsafari Feb 28 '13 at 18:04
  • Hmm...I think I'd try temporarily removing the `ScrollView` and just keeping the `TableLayout` - and copy the `ScrollView`'s layout parameters to the `TableLayout`. That will remove any oddities that may come with a scrolling control. Once you get that working, then you can put the scrollview back in. If it doesn't work then, you'll know it's something specific to the scrollview. – Todd Sjolander Feb 28 '13 at 18:19
  • Oh, one more thing, although not causing your problem - Your first `LinearLayout` with the id of `header` could be removed. Use android:layout_centerHorizontal="true" in the `TextView`. – Todd Sjolander Feb 28 '13 at 18:24
  • Ok, well removing the scroll view and setting the table view to display below the header works as I want. However i need the scroll view as the table view when populated with content is larger than the screen. – cosmicsafari Feb 28 '13 at 18:31
  • Great! Progress. Now your problem is how to make the table scroll. Some links: http://stackoverflow.com/questions/5078268/how-to-implement-scrolling-in-tablelayout and http://stackoverflow.com/questions/1399605/problem-in-horizontal-scroll-in-android – Todd Sjolander Feb 28 '13 at 18:38
0

try it now

 <?xml version="1.0" encoding="utf-8"?>
     <!-- ViewFlipper -->
            <ViewFlipper
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/ViewFlipper01"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                >
    <!-- Page 1 (Splash) -->
         <LinearLayout
              android:id="@+id/splashPage"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical" >
               <TextView
               android:id="@+id/splash"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent" 
               android:text="Display Splash Image"/>
         </LinearLayout>
    <!-- Page 2 (Main) -->
        <RelativeLayout
            android:id="@+id/mainPage"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical">
            <LinearLayout
            android:id="@+id/header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_below="@+id/mainPage"
            >
                    <TextView
                   android:id="@+id/date"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content" 
                   android:gravity="center_horizontal" />
            </LinearLayout>
            <ScrollView
            android:id="@+id/scrollView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
    android:layout_above="@+id/buttonHolder"
            android:layout_below="@+id/header"
            >
                  <TableLayout
                   android:id="@+id/tableHolder"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content" >
                        <!-- Dynamic TextViews Will Go In Here -->
                  </TableLayout>
            </ScrollView>
            <LinearLayout
            android:id="@+id/buttonHolder"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
            android:orientation="horizontal"
            android:layout_below="@+id/scrollView" 
            >
              <Button
               android:id="@+id/previous"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Previous" />
              <Button
               android:id="@+id/next"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Next" />
            </LinearLayout>
        </RelativeLayout>   
     </ViewFlipper> 
     <!-- End of ViewFlipper -->
Karan_Rana
  • 2,813
  • 2
  • 26
  • 35