【问题标题】:Divider not working in my listview分隔线在我的列表视图中不起作用
【发布时间】:2010-09-04 01:26:51
【问题描述】:

我正在尝试在我的简单列表视图中使用渐变分隔线。但它根本行不通。

布局xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:id="@+id/main_layout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/wood_small"
    android:padding="5dip" xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:id="@+id/masthead_image" android:layout_gravity="center_horizontal" 
        android:src="@drawable/tavi_mh_copy">
    </ImageView>

    <ListView  android:id="@+id/station_list" 
        android:layout_height="fill_parent" android:layout_width="fill_parent"
        android:divider="@drawable/black_white_gradient" android:dividerHeight="2px">
    </ListView>

</LinearLayout>

分隔符 Xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <gradient
      android:startColor="#00222222"
      android:centerColor="#FFFFFFFF"
      android:endColor="#00222222"
      android:angle="0" />
</shape>

【问题讨论】:

  • @Programmer 请通过将整个代码块缩进 4 个空格来使用代码块(ctrl + K 或使用工具栏上的代码按钮)。您不必以这种方式转义尖括号。
  • @Yijiang 我在使用该功能时遇到了一些奇怪的事情。因此,正如我看到其他人所做的那样,我只是将代码包装在标签中并在必要时转义 html。我会看看我是否能得到首选的行为方式。
  • 好的。我使用首选方法使这个看起来不错。

标签: android android-listview


【解决方案1】:

这已解决。不完全确定它为什么工作,但我重新创建了相同的布局并开始工作。也许是星星的位置之类的。

谢谢大家, 机器人

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-19
    相关资源
    最近更新 更多