1

http://realdevs.tistory.com/entry/asdf

↑ Picture.

I have a problem when I use ListView.

As the screen is full of widgets, I would like the ListView's items to be scrolled with other items in the layout.

On the picture, the blue one is a widget on the layout, and the red ones are the items of ListView.

When I scroll up the items, they move, but the blue one doesn't.

How can I make it to move together with ListView as it is an item in ListView?

Namnamseo
  • 187
  • 1
  • 15

3 Answers3

1

you an add your blue layout as your listView header.

this will help you in adding a layout as header.

Community
  • 1
  • 1
Mohsin Naeem
  • 12,542
  • 3
  • 39
  • 53
0

Simply add that blue part in scrollview

 <ScrollView
           xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"  
           >

your layout
........


 </ScrollView>
Furqi
  • 2,403
  • 1
  • 26
  • 32
  • 5
    it is not a good practice to include listview under scrollview.it wont work efficiently. – AkashG Jul 25 '12 at 05:56
  • Don't put a ListView inside an ScrollView (with `android:orientation="vertical"`). It destroy the whole purpose of using the ListView. Not a good practice. – AnujAroshA Jul 25 '12 at 05:58
  • he does not mention that blue area is inside listview thats why i suggest him to add that blue area inside scroll view and you can give weight. – Furqi Jul 25 '12 at 06:05
0

From your pic in http://realdevs.tistory.com/entry/asdf

I'm implement in coding xml this.

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#e0e0e0"
    android:orientation="vertical" >

    <!-- this layout add your other items. I'm exam add Button -->
    <Button
        android:id="@+id/butonTop"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:text="Top Button" />

</LinearLayout>

<!-- ListView in bottom screen and can auto scroll.  --> 
<ListView
    android:id="@+id/dataListView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="5dp"
    android:drawSelectorOnTop="false" >
</ListView>

</LinearLayout>

jiw_cs
  • 761
  • 6
  • 2