Разделитель между ListView и TextView на Android - PullRequest
0 голосов
/ 03 июня 2011

Как вы можете видеть на изображении ниже, под ListView появляются черные линии перед TextView (нижний колонтитул).

enter image description here

Я не могу понять, связано ли этонижний отступ списка или верхний отступ текста, поэтому я попытался манипулировать макетом xml, добавив android: layout_marginBottom = "0px" и android: paddingBottom = "0px" в просмотр списка и android: paddingTop = "0px"android: layout_marginTop = "0px" в текстовое представление, но ничего не работает!

Пожалуйста, помогите мне, потому что я не знаю, как решить проблему !!!

Вот xmls макета...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
 <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/header"
    android:id="@+id/header"
    android:gravity="center"
    android:textSize="22sp"
    android:background="#777777"
/>
<ListView
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:id="@+id/items_list"
    android:divider="#00000000"
    android:dividerHeight="0px"
    android:footerDividersEnabled="false"
    android:layout_marginBottom="0px"
    android:paddingBottom="0px"
/>      
<TextView 
    android:paddingTop="0px"
    android:layout_marginTop="0px"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:text="@string/footer" 
    android:gravity="center" android:textSize="22sp"
    android:background="#777777/>
</LinearLayout>

А вот расположение элемента в списке

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:paddingBottom="0px"
    android:layout_marginBottom="0px"
    android:background="#777777">

    <TextView 
        android:layout_width="fill_parent" 
        android:text="Item List"
        android:layout_height="wrap_content" 
        android:id="@+id/item"
        android:textSize="22sp" 
    />
    <TextView 
        android:layout_width="fill_parent" 
        android:text="List Item bottom"
        android:layout_height="wrap_content" 
        android:id="@+id/item2"
        android:textSize="14sp" 
        android:layout_below="@id/item"
        android:layout_alignParentBottom="true" 
    />
    <TextView 
        android:layout_width="wrap_content" 
        android:text="List Item right"
        android:layout_height="wrap_content" 
        android:id="@+id/item3"
        android:textSize="16sp" 
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true" 
      />
</RelativeLayout>

Ответы [ 2 ]

2 голосов
/ 03 июня 2011

Похоже, это ошибка. Есть взлом. В вашем ListView напишите это:

<ListView ... android:layout_marginBottom="-3dp" />

Это решит эту конкретную проблему.

Сказав это, я хочу упомянуть еще раз, что вы должны использовать ListView.addFooterView() или вы можете использовать layout_weight:

<ListView       
    android:layout_width="fill_parent"
    android:layout_height="0dp"         
    android:layout_weight="1"
    android:background="#888888"
    ...
/>

enter image description here

Выберите подход, который вам больше всего подходит. Но обратите внимание, что «-3dp» - это взлом, и его не следует использовать (если вы не в отчаянии :).

0 голосов
/ 03 июня 2011

Попробуйте установить для атрибута android: footerDividersEnabled значение false и посмотрите, поможет ли это.

...