【问题标题】:How to hide the horizontal line at the bottom of each item in android listview? [duplicate]如何隐藏android listview中每个项目底部的水平线? [复制]
【发布时间】:2011-09-23 07:18:57
【问题描述】:

在android listview中,默认情况下,每个项目的底部似乎都有一条水平线。我的问题是:如何让行不显示

【问题讨论】:

    标签: android listview


    【解决方案1】:

    在这里查看:How to change color of Android ListView separator line?

    您可以尝试将分隔线高度设置为 0px。

    【讨论】:

      【解决方案2】:

      您可以使用此代码..

      lvlist.setDivider(null);
      lvlist.setDividerHeight(0);
      

      【讨论】:

      • 您的解决方案有效。是否可以通过 xml 配置来实现?
      • @David 可以试试 android:dividerHeight="0px" 。如果您认为这有帮助,请正确回答并投票以帮助其他人。
      • @David android:divider="#00000000" android:dividerHeight="0px"
      • 感谢它对我有用。 :)
      • android:divider="#00ffffff" android:dividerHeight="0px" 为我解决了问题。布局中不允许 Null 作为分隔符的值。
      【解决方案3】:

      在xml中:

      android:divider="@null"
      android:dividerHeight="0dp"
      

      在java中你可以使用这个:

      myList.setDivider(null);
      myList.setDividerHeight(0);
      

      【讨论】:

        【解决方案4】:

        有不同的方法可以实现这一点,但我不确定哪一种是最好的(我什至不知道有没有最好的方法)。我知道在 ListView 中至少有两种不同的方法:

        1.将分隔符设置为空:

        1.1。以编程方式

        yourListView.setDivider(null);
        

        1.2。 XML

        android:divider="@null" (this goes inside your ListView element)
        

        2。将分隔线设置为透明并将其高度设置为 0,以避免在列表视图元素之间添加空间:

        2.1。以编程方式:

        yourListView.setDivider(new ColorDrawable(android.R.color.transparent));
        yourListView.setDividerHeight(0);
        

        2.2。 XML

        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        

        【讨论】:

          猜你喜欢
          • 2014-09-07
          • 1970-01-01
          • 2011-04-22
          • 2011-02-07
          • 1970-01-01
          • 1970-01-01
          • 2010-09-26
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多