Can I add a Scrollview to this Xml?

Go To StackoverFlow.com

-1

Been trying to figure this out.. I am new to Adroid and trying to get the whole screen to scrollview...it's a header image and a list...would like it to all scroll together. Can it be done using this layout? Thanks!

<?xml version="1.0" encoding="UTF-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/containerView"
    android:background="@android:color/transparent"    
    android:padding="0dip"
    android:layout_margin="0dip"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/headerImageContainer"
        android:background="@android:color/transparent"    
        android:padding="0dip"
        android:layout_margin="0dip"
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content">

            <ImageView 
                  xmlns:android="http://schemas.android.com/apk/res/android"               
            android:id="@+id/headerImageView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleType="center"
            android:layout_centerHorizontal="true"
            android:layout_alignParentTop="true">
        </ImageView>

    </LinearLayout>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/listViewContainer"
        android:background="@android:color/transparent"    
        android:paddingLeft="35dip"
            android:paddingRight="35dip"
            android:paddingTop="10dip"
            android:paddingBottom="0dip"

        android:layout_margin="0dip"
        android:layout_weight="1"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:layout_below="@+id/headerImageContainer">

        <ListView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/listView"
            android:background="@android:color/transparent"    
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:cacheColorHint="#000000"

            android:choiceMode="singleChoice" 
            android:layout_weight="1"
            android:scrollbars="none">
        </ListView>

    </LinearLayout>

   </RelativeLayout>
2012-04-05 02:30
by user1120680


0

what do you mean by scroll together. If you wanna to scroll image as well when you move from item 1 to item n. then instead of using scroll view better to integrate your list view with a image in first row or make that image as header for the the list items. Scroll view is used to scroll where as list view has in built scroll view hat scrolls the items.

2012-04-05 02:44
by Shankar Agarwal
thanks for the response :) my firs time asking a question - user1120680 2012-04-05 04:46


0

Encapsulate everything you have in

<LinearLayout
 ...>
    <ScrollView
     ...>
         Your original XML content here
    </ScrollView>
</LinearLayout>

And it should work.

2012-04-05 03:05
by Kai
Thanks for the response. Have a lot to learn yet.. Because of the Java code wanting the Relativelayout that this XML code has I am having a hard time with this...any other tips greatly appreciated. thanks so much : - user1120680 2012-04-05 03:53
Glad to help, remember to accept an answer by clicking on the "mark" sign - Kai 2012-04-05 04:09
I got it kinda working but had to give thelistview a large number width and height ...now when I rotate the screen to landscape the top header image is out of view and when rotated back to portrait it is out of view as well...have to pull down on menu to see the header image. thanks again for any help - user1120680 2012-04-05 04:45
Hmmm, guess it's just not possible...the only thing I can come up with is to make the listview height=1000dip...it scrolls but header image out of view on start of screen : - user1120680 2012-04-05 06:19
Ads