2016-12-24 3 views
1

Я пытаюсь добавить LinearLayout под номером listView, но он имеет пробел между ListView и LinearLayout. Как его удалить? Большое спасибо.Добавить LinearLayout под спискомView

<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> 

Ниже показать мое изображение

enter image description here

+1

Попробуйте удалить 'Android: layout_alignParentBottom' в Уре ListView. Или сделайте свою внутреннюю RelativeLayout высотой match_parent. –

+0

Попробуйте удалить андроид: paddingBottom = "@ dimen/activity_vertical_margin" из вашего родительского макета – Bhavnik

+2

@Bhavnik [просьба не отвечать в комментариях, читать на SO] (http://stackoverflow.com/help/privileges/comment), особенно когда то ответ уже есть, вы можете похвалить ответ, если хотите –

ответ

3

Вы должны удалить этот атрибут 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"> 

paddingBottom разместит разрыв между ваш родительский родственник макет и нижняя часть экрана

1

Пробел в нижней части создается в самом начале вашего кода. Чтобы избавиться от него, удалите из своего сравнительного макета следующее.

android:paddingBottom="@dimen/activity_vertical_margin" 
2

удалить этот атрибут андроид: 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>