1

I trying to add a LinearLayout under the listView but it has a space between ListView and the LinearLayout.How to remove it ? Thanks a lot.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <ImageView
        android:src="@drawable/expenses"
        android:layout_marginTop="50dp"
        android:layout_width="130dp"
        android:layout_height="210dp"
        android:id="@+id/imageView"
        android:gravity="center"
        android:layout_centerHorizontal="true"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:text="You haven't added any expenses yet"
        android:textSize="15dp"
        android:textColor="@color/btn_login"
        android:gravity="center"
        android:id="@+id/NoData"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/imageView"/>

    <Button
        android:layout_width="250dp"
        android:layout_height="60dp"
        android:text="Add Expenses"
        android:id="@+id/button"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/NoData"/>

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

        <ListView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/listview"
            android:footerDividersEnabled="false"
            android:layout_weight="1"
            android:layout_alignParentBottom="true" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="bottom"
            android:background="@color/light_gray"
            android:orientation="horizontal"
            android:id="@+id/linearLayout"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true">

            <TextView
                android:layout_marginLeft="100dp"
                android:id="@+id/Remaining"
                android:paddingTop="10dp"
                android:textSize="20sp"
                android:layout_width="90dp"
                android:layout_height="40dp"
                android:text="Balance : " />

            <TextView
                android:layout_marginLeft="10dp"
                android:id="@+id/balance"
                android:paddingTop="10dp"
                android:textSize="20sp"
                android:layout_width="79dp"
                android:layout_height="40dp"
                android:text="balance " />
        </LinearLayout>
    </RelativeLayout>
</RelativeLayout>

Below show my image

enter image description here

AI.
  • 934
  • 2
  • 14
  • 30
  • 1
    Try removing `android:layout_alignParentBottom` in ur ListView. Or make your inner RelativeLayout's height match_parent. – Shreyash S Sarnayak Dec 24 '16 at 06:51
  • Try removing android:paddingBottom="@dimen/activity_vertical_margin" from your parent layout – Bhavnik Dec 24 '16 at 07:03
  • 2
    @Bhavnik [please don't answers in comments , read on SO](http://stackoverflow.com/help/privileges/comment) especially when then answer is already there , you can compliment the answer if you please – Pavneet_Singh Dec 24 '16 at 07:06

3 Answers3

3

You need to remove this attribute android:paddingBottom="@dimen/activity_vertical_margin"

so it should look like this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

paddingBottom will place a gap between your parent relative layout and the bottom of the screen

Pavneet_Singh
  • 36,884
  • 5
  • 53
  • 68
2

remove this attribute android:paddingBottom="@dimen/activity_vertical_margin"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ImageView
        android:src="@drawable/expenses"
        android:layout_marginTop="50dp"
        android:layout_width="130dp"
        android:layout_height="210dp"
        android:id="@+id/imageView"
        android:gravity="center"
        android:layout_centerHorizontal="true"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:text="You haven't added any expenses yet"
        android:textSize="15dp"
        android:textColor="@color/btn_login"
        android:gravity="center"
        android:id="@+id/NoData"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/imageView"/>

    <Button
        android:layout_width="250dp"
        android:layout_height="60dp"
        android:text="Add Expenses"
        android:id="@+id/button"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/NoData"/>

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

        <ListView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/listview"
            android:footerDividersEnabled="false"
            android:layout_weight="1"
            android:layout_alignParentBottom="true" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="bottom"
            android:background="@color/light_gray"
            android:orientation="horizontal"
            android:id="@+id/linearLayout"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true">

            <TextView
                android:layout_marginLeft="100dp"
                android:id="@+id/Remaining"
                android:paddingTop="10dp"
                android:textSize="20sp"
                android:layout_width="90dp"
                android:layout_height="40dp"
                android:text="Balance : " />

            <TextView
                android:layout_marginLeft="10dp"
                android:id="@+id/balance"
                android:paddingTop="10dp"
                android:textSize="20sp"
                android:layout_width="79dp"
                android:layout_height="40dp"
                android:text="balance " />
        </LinearLayout>
    </RelativeLayout>
</RelativeLayout>
Joy Joy
  • 51
  • 6
1

The white space on the bottom is created at the very beginning of your code. To get rid of it remove the following from your Relative Layout.

android:paddingBottom="@dimen/activity_vertical_margin"