在列表视图末尾的两个listview片段中添加边框

时间:2016-02-13 11:23:25

标签: android listview android-fragments

正如标题所说,我有一个包含两个列表视图的片段,我想在第二个列表视图的末尾添加一个边框。我知道这通常是在xml写作中实现的:

android:paddingBottom="50dp"
android:clipToPadding="false"

当我只使用一个listView时,它可以完美运行,但不是两个,我不知道为什么。 我尝试在我的baseAdapter的getView中添加一个白色布局,但问题是我想管理长时间点击我使用的是:

listViewSin.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
listViewSin.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {...});

在这种方法中我无法知道在创建菜单之前点击的视图类型,因此我不想添加新视图。

布局代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="10dip" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:text="@string/sin"
            android:textColor="@color/black"
            android:textSize="15sp"
            android:id="@+id/android"/>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#000000"
            />


        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:divider="@null"
            android:dividerHeight="0dp"
            android:background="#FFFFFF"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:gravity="center_vertical"
            android:text="@string/hechos"
            android:textColor="#A2A2A2"
            android:id="@+id/ios"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#A2A2A2"
            />

        <ListView
            android:id="@+id/listView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:background="#A2A2A2"
            android:divider="@null"
            android:dividerHeight="0dp"
            android:paddingBottom="80dp"
            android:clipToPadding="false"
            />

    </LinearLayout>

</ScrollView>
<android.support.design.widget.FloatingActionButton
    android:id="@+id/tareas_add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:src="@drawable/add"
    android:layout_marginRight="10dp"
    android:layout_marginBottom="10dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_marginEnd="10dp" />

1 个答案:

答案 0 :(得分:0)

以类似于此处所解释的方式定义可绘制的形状:

Android border bottom for custom view not working

将矩形的颜色设置为ListView's背景颜色,将笔触颜色设置为所需的底部边框颜色。然后在xml中,在ListView元素背景属性中,使用@drawable /...引用形状。