【问题标题】:TouchListview with fixed footer带有固定页脚的 TouchListview
【发布时间】:2011-11-14 20:45:09
【问题描述】:

我的问题应该在这里回答:Fixed footer not displaying the bottom-most list item

但这对我不起作用。

我想要一个底部有固定页脚的列表视图。此刻,列表视图与窗口一样大,这使得页脚重叠。 XML:

<?xml version="1.0" encoding="utf-8" ?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:orientation="vertical">

  <!-- <ImageView 
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:src="@drawable/baby_blue_solid" android:scaleType="centerCrop" />-->
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/footer_cloud"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:layout_alignParentBottom="true"
    >

    <ImageView android:id="@+id/add_icon"
        android:layout_centerInParent="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
                android:src="@drawable/ic_menu_add"
    />

    <ImageView android:id="@+id/cloudBG"
        android:layout_centerInParent="true"
        android:layout_width="230dp"
        android:layout_height="60dp"
        android:background="@drawable/cl"

    />

    <ImageView 
        android:id="@+id/footer_divider"
        android:layout_width="fill_parent"
        android:layout_height="2dp"
        android:background="@android:drawable/divider_horizontal_bright"
        android:layout_above="@id/cloudBG"
    />


    </RelativeLayout>

<com.commonsware.cwac.tlv.TouchListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tlv="http://schemas.android.com/apk/res/com.commonsware.cwac.tlv.demo"

    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/root"
    android_layout_above="@id/footer_cloud"
    android:drawSelectorOnTop="false"
    android:listSelector="@android:color/transparent"

    tlv:normal_height="64dip"
    tlv:grabber="@+id/icon"
    tlv:remove_mode="slideLeft"

/>

</RelativeLayout>

虽然我使用 Commonsware 的 touchlistview,但我认为这不应该是它不起作用的原因。谁能看出错误?

另外,我看不到我实现的分隔线。当我使用 background 或 src 属性时,都看不到效果。

【问题讨论】:

  • 该站点建议列表的高度为 0dp:blog.maxaller.name/2010/05/… 对我来说,这只是使列表不可见。顺便说一下,它被一个数组适配器填充了

标签: android layout footer commonsware-cwac


【解决方案1】:

首先,在诊断问题时尽可能使用更简单的小部件。如果您发现 TouchListView 的异常之处,请尝试使用常规的 ListView

其次,TouchListView 的布局规则很奇怪。您正在尝试使小部件位于其自己的容器下方。而且,您应该使用0dp 作为高度。

试试那些东西。如果问题仍然存在并且是TouchListView 独有的,我将需要一个示例项目来重现错误以进一步调查。如果常规 ListView 出现问题,而我在这里写的内容没有帮助,下一步是使用 Hierarchy View 尝试诊断您的布局有什么问题。

【讨论】:

  • 感谢您的建议。我将列表高度更改为 0dp,将 touchlistview 替换为 listview。在没有任何改变之后,我尝试了层次结构查看器。我注意到 id/root 的 3 个子项:列表、页脚和背景图像视图。我怀疑背景可能是问题,所以我删除了它,但没有效果。 Root 现在有两个孩子。页脚有 alignparentbottom 和列表有 above:footer
猜你喜欢
  • 2019-10-29
  • 1970-01-01
  • 2019-02-14
  • 2015-02-02
  • 2014-08-14
  • 2012-02-28
  • 1970-01-01
  • 2011-12-27
  • 1970-01-01
相关资源
最近更新 更多