0

I want to use two listview with my bottom functionality in a layout. Here is my layout file. I just want if my parent layout fill hole screen then child will comes after parent layout and i want also show my bottom layout as it is. please help me solve this. Thank You :)

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

<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
xmlns:android="http://schemas.android.com/apk/res/android">

<ListView
    android:id="@+id/my_cart_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>
<ListView
    android:id="@+id/my_ecart_list"
    android:layout_below="@+id/my_cart_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/rr"
    android:layout_weight="1"/>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:id="@+id/rr"
    android:background="#FA0"
    android:layout_marginBottom="0dp">

    <TextView
        android:id="@+id/item_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Items"
        android:textColor="#000"
        android:textSize="17sp"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="20dp"/>

    <TextView
        android:id="@+id/cart_item_count"
        android:layout_toRightOf="@+id/item_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="(2)"
        android:textColor="#000"
        android:textSize="17sp"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="5dp"/>


    <TextView
        android:id="@+id/total_cart_amount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000"
        android:textSize="20sp"
        android:layout_alignTop="@+id/cart_item_count"
        android:layout_centerHorizontal="true" />

    <Button
        android:id="@+id/checkout_cart"
        android:layout_width="wrap_content"
        android:layout_height="25dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="4dp"
        android:layout_marginTop="4dp"
        android:padding="3dp"
        android:text="Checkout >>"
        android:textSize="16dp" />

    <TextView
        android:id="@+id/mycart_empty"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="CART IS EMPTY"
        android:gravity="center"
        android:textColor="#000"
        android:textSize="22sp"
        android:layout_marginTop="12dp"/>

</RelativeLayout>
</RelativeLayout>

3 Answers3

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

    <ListView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <ListView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

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

        <!-- your button layout goes here -->
    </RelativeLayout>

</LinearLayout>

if you want to auto adjust the height of your view(list view here) then set your height as 0dp and set the weight as you want.

EDIT: Sorry my bad i have updated the code.

Nishant Pardamwar
  • 1,450
  • 12
  • 16
0

Visit this.

Or copy this fragment:

<?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="fill_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >
    </ListView>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:text="Button" />

</LinearLayout>
Nikita G.
  • 720
  • 1
  • 14
  • 22
0

Replace Your xml with this code.

<?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="fill_parent"
    android:orientation="vertical"
    android:weightSum="1">

    <ListView
        android:id="@+id/my_ecart_list"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.45" />

    <ListView
        android:id="@+id/my_cart_list"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.45" />

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/rr"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.1"
        android:background="#FA0">

        <TextView
            android:id="@+id/item_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="15dp"
            android:text="Items"
            android:textColor="#000"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/cart_item_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="15dp"
            android:layout_toRightOf="@+id/item_text"
            android:text="(2)"
            android:textColor="#000"
            android:textSize="17sp" />


        <TextView
            android:id="@+id/total_cart_amount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/cart_item_count"
            android:layout_centerHorizontal="true"
            android:textColor="#000"
            android:textSize="20sp" />

        <Button
            android:id="@+id/checkout_cart"
            android:layout_width="wrap_content"
            android:layout_height="25dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="4dp"
            android:layout_marginTop="4dp"
            android:padding="3dp"
            android:text="Checkout >>"
            android:textSize="16dp" />

        <TextView
            android:id="@+id/mycart_empty"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dp"
            android:gravity="center"
            android:text="CART IS EMPTY"
            android:textColor="#000"
            android:textSize="22sp" />

    </RelativeLayout>


</LinearLayout>
Suhas Bachewar
  • 1,230
  • 7
  • 21
  • @yogipuranik if it works then accept answer & vote up . – Suhas Bachewar Jun 09 '16 at 08:30
  • sir their is another problem in this app plz solve this error please.. http://stackoverflow.com/questions/37729877/how-to-add-two-fixed-tab-into-my-activity-and-get-listview-into-that-tabs?noredirect=1#comment62931805_37729877 – yogi puranik Jun 10 '16 at 05:08
  • @yogipuranik I have seen and comment on your question I will help you for that question. You are not still accept answer & not vote up. – Suhas Bachewar Jun 10 '16 at 05:23
  • i dont know where n how can vote up..sorry i m clicking on that i wll gives toast msg thank you for feedback.. – yogi puranik Jun 10 '16 at 05:41
  • @yogipuranik sorry but you can accept answer you own't be vote up because you don't have 50 reputations. – Suhas Bachewar Jun 10 '16 at 05:42
  • Sorry sir..n thank u and sir can u see my new my new comment on that above post plz read that their is another problem – yogi puranik Jun 10 '16 at 06:05