0

There is a list view and other text views in my screen. I want to show the list in whole the screen and other elements in the bottom of the list.

Below is the code I used.

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relative_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_light_blue" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/background_light_blue"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/header1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@layout/header_gradients"
            android:orientation="vertical"
            android:paddingBottom="8dip"
            android:paddingTop="8dip" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_marginLeft="10dip"
                android:layout_weight="1"
                android:gravity="center"
                android:text="@string/shopping_cart"
                android:textColor="@color/white"
                android:textSize="15sp"
                android:textStyle="bold" />
        </LinearLayout>

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/background_light_blue"
                android:orientation="vertical" >

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dip"
                    android:layout_marginRight="5dip"
                    android:layout_marginTop="5dip"
                    android:background="@color/white"
                    android:orientation="horizontal"
                    android:padding="5dp" >

                    <TextView
                        android:id="@+id/purchase_order"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="6dp"
                        android:layout_marginTop="2dp"
                        android:text="Requisitioner"
                        android:textColor="@color/black"
                        android:textSize="15sp"
                        android:typeface="sans" />

                    <TextView
                        android:id="@+id/requisitioner"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/purchase_order"
                        android:layout_marginBottom="3dp"
                        android:layout_marginLeft="6dp"
                        android:layout_marginTop="5dp"
                        android:text="Requisitioner"
                        android:textColor="@color/black"
                        android:textSize="15sp" />

                    <ImageView
                        android:id="@+id/imageView1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_centerVertical="true"
                        android:contentDescription="@string/image"
                        android:src="@drawable/shopping_cart" />
                </RelativeLayout>

                <TextView
                    android:id="@+id/products_and_services"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="3dp"
                    android:layout_marginTop="15dp"
                    android:gravity="center_horizontal"
                    android:text="@string/products_and_services"
                    android:textColor="@color/black"
                    android:textSize="17sp"
                    android:textStyle="bold" />

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

                    <LinearLayout
                        android:id="@+id/lr1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical" >

                        <ListView
                            android:id="@android:id/list"
                            android:layout_width="wrap_content"
                            android:layout_height="0dp"
                            android:layout_marginLeft="5dp"
                            android:layout_marginRight="5dp"
                            android:layout_weight="0.12" >
                        </ListView>
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/pagingPanel"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/lr1"
                        android:background="@drawable/background_light_blue"
                        android:orientation="vertical" >

                        <TextView
                            android:id="@+id/note_to_approver"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="3dp"
                            android:layout_marginTop="10dp"
                            android:gravity="center_horizontal"
                            android:text="@string/note_to_approver"
                            android:textColor="@color/black"
                            android:textSize="17sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/note"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_marginRight="5dp"
                            android:layout_marginTop="2dp"
                            android:background="@color/white"
                            android:maxLines="10"
                            android:padding="5dp"
                            android:text="hijnjn"
                            android:textColor="@color/black"
                            android:textSize="15sp"
                            android:typeface="sans" />

                        <TextView
                            android:id="@+id/approver"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="1dp"
                            android:layout_marginTop="15dp"
                            android:gravity="center_horizontal"
                            android:text="@string/approvers"
                            android:textColor="@color/black"
                            android:textSize="17sp"
                            android:textStyle="bold" />

                        <Button
                            android:id="@+id/approvers"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:layout_marginRight="5dp"
                            android:layout_marginTop="5dp"
                            android:background="@drawable/options_menu"
                            android:drawableRight="@drawable/arrow_right"
                            android:gravity="left|center"
                            android:text="@string/approvers"
                            android:textColor="@color/black"
                            android:textSize="16sp"
                            android:textStyle="bold"
                            android:typeface="sans" />
                    </LinearLayout>
                </RelativeLayout>
            </LinearLayout>
        </ScrollView>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:background="@layout/btn_background" >

        <Button
            android:id="@+id/release_button"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="5dp"
            android:layout_weight="1"
            android:background="@drawable/btn_blue"
            android:text="Approve(1)/Reject(0)"
            android:textColor="@color/white"
            android:textSize="15sp"
            android:textStyle="bold" />
    </LinearLayout>

</RelativeLayout>

Now the screens is looking like this

My requirement: Now the list is scrolling within the given area. I want to show in the whole screen and the scrolling should be only for the screen.

Please help me to do this.

MidhunVP
  • 63
  • 2
  • 7
  • I'm not sure if I understand your question right. Do you want a List which last element contains the textviews? So the textviews would only be visible when you scroll to the bottom of the list? – Sven Apr 23 '13 at 14:56
  • if this is the case you can use the method `addFooterView` of the ListView. See this [question](http://stackoverflow.com/a/4265324/702478) for a code example – Sven Apr 23 '13 at 15:04
  • I want to show the complete list in the screen and the text views below it. The user will see these texts only when the user scroll the screen to the bottom. I need scrolling for the screen instead of scrolling the list. – MidhunVP Apr 23 '13 at 15:09

1 Answers1

0

You should not put a Vertically scrolling widget/view (ListView) in another vertically scrolling view (ScrollView). Though there are a few ways mentioned here and here which might help you achieve what you wish but that will increase the CPU load.

Community
  • 1
  • 1