0


I have layout like this At the top i have listView ,below that i have LinearLayout (the one with radio button Add New Addess).
Now Issue is my listView and linearlayout are overlapping . Kindly help me .


enter image description here

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

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

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="63dp"
        android:layout_weight="0.05" >

        <ImageView
            android:id="@+id/menu_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:src="@drawable/hs18_logo" />

        <ImageView
            android:id="@+id/setting_icon"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="17dp"
            android:scaleType="fitCenter"
            android:src="@drawable/menu" />

        <ImageButton
            android:id="@+id/signin_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/setting_icon"
            android:layout_marginRight="20dp"
            android:background="@android:color/transparent"
            android:src="@drawable/signin"
            android:visibility="invisible" />
    </RelativeLayout>

    <TextView
        android:id="@+id/cart_checkout_title"
        android:layout_width="fill_parent"
        android:layout_height="35dp"
        android:background="@color/gray"
        android:gravity="center"
        android:text="Shipping Address"
        android:textStyle="bold" />

    <ListView
        android:id="@+id/shipping_addresses_listView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.90" >
    </ListView>

    <include layout="@layout/shipping_add_adresss" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_weight="0.05"
        android:gravity="center" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonshape_white"
            android:text="Cancel"
            android:textColor="@color/red" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:background="@drawable/buttonshape_red"
            android:text="Update Shipping Address"
            android:textColor="@color/white" />
    </LinearLayout>
</LinearLayout></ScrollView>
Code_Life
  • 5,742
  • 4
  • 29
  • 49
  • @DevuSoman : will it add the linearlayout at the end last element of listview – Code_Life Jan 04 '13 at 06:09
  • where is closing of srollview. put your full xml code. – sandy Jan 04 '13 at 06:10
  • @sandy : check the edit .. some issue with SO – Code_Life Jan 04 '13 at 06:15
  • get your listview out of scrollview http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android?rq=1 – sandy Jan 04 '13 at 06:29
  • @sandy : my view is large . if i remove scrollview ..my layout wont fit on screen ..... my main aim is just to place these layout at the end of the listview – Code_Life Jan 04 '13 at 06:41
  • @MohitSharma You can do one thing: have only ListView in the Layout.xml. And **my main aim is just to place these layout at the end of the listview**, you can set that huge layout as a FooterView to your ListView. That way, you will see only the ListView initailly and once you scroll to the end of the List, you can see your LinearLayout. But how big is your ListView(how many items?) moreover does the count change frequently? – Archie.bpgc Jan 04 '13 at 06:45
  • @Archie.bpgc : Max 10 elements and layout which i want to add is show n in figure . – Code_Life Jan 04 '13 at 06:51
  • Thanks for Effort .. All – Code_Life Jan 04 '13 at 07:06

3 Answers3

1

use layout_above property for listview.

android:layout_above="@+id/linear_layout"
RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
1

@MohitSharma Always remember

Never use a ListView in a ScrollView

for reasons check this:

ListView inside ScrollView is not scrolling on Android

What ever the requirement is you can do it by using just one of them(ListView or ScrollView).

So, for your case you can do either of the 2 things below:

  • Have only ListView in your Layout.xml and you can set that huge layout as a FooterView to your ListView.
  • If you want to use a ScrollView, remove the ListView and dynamically add those List Items as normal Layouts(Linear/RelativeLayout).

first approach is more recommended.

Community
  • 1
  • 1
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
  • Because if its a static List with <10 items, you can avoid using ListView and just add them to the ScrollView like other Layouts – Archie.bpgc Jan 04 '13 at 07:09
  • You will be adding the FooterView after inflating the Layout. So, once you have a View, you can play around with it. Like `CheckBox cb = (CheckBox) mFooter.findViewById(R.id.mfooter);` – Archie.bpgc Jan 04 '13 at 08:31
  • Hi .. sorry to bug u again .. i have another problem ... my spinner is not able to get itemselect listerner .. .. Pls .. help me – Code_Life Jan 08 '13 at 07:57
0

Try this work for you i have checked it.

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="5dp">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="63dp">

    <ImageView
        android:id="@+id/menu_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/hs18_logo" />

    <ImageView
        android:id="@+id/setting_icon"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="17dp"
        android:scaleType="fitCenter"
        android:src="@drawable/menu" />

    <ImageButton
        android:id="@+id/signin_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/setting_icon"
        android:layout_marginRight="20dp"
        android:background="@android:color/transparent"
        android:src="@drawable/signin"
        android:visibility="invisible" />
</RelativeLayout>

<TextView
    android:id="@+id/cart_checkout_title"
    android:layout_width="fill_parent"
    android:layout_height="35dp"
    android:background="@color/gray"
    android:gravity="center"
    android:text="Shipping Address"
    android:textStyle="bold" />

<ListView
    android:id="@+id/shipping_addresses_listView"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
       >
</ListView>
</LinearLayout>
</ScrollView>

& if you Add Layout After Listview Give id to scrollview & add Layout in Scrollview this is perfectly work for you.

Dixit Patel
  • 3,190
  • 1
  • 24
  • 36
  • what do mean by " & if you Add Layout After Listview Give id to scrollview & add Layout in Scrollview this is perfectly work for you." – Code_Life Jan 04 '13 at 06:46