【问题标题】:How to remove border around grid-view如何删除网格视图周围的边框
【发布时间】:2015-11-25 09:41:52
【问题描述】:

这是我尝试使用android:listSelector="@null"的网格视图布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#191919">

        <GridView
            android:id="@+id/gridView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:columnWidth="100dp"
            android:drawSelectorOnTop="true"
            android:gravity="center"
            android:numColumns="auto_fit"
            android:stretchMode="columnWidth"
            android:verticalSpacing="5dp"
            android:focusable="true"
            android:clickable="true"
            android:listSelector="@null"/>

    </RelativeLayout>

但我无法摆脱网格视图中的这些黑色边框

【问题讨论】:

  • 黑色是gridview的颜色
  • 但是当我向上或向下滚动时,黑色边框与绿色重叠
  • 请发布您的包含gridlayout的xml布局
  • @PhanVănLinh 好的,谢谢,你基本上帮我弄清楚了。

标签: android


【解决方案1】:

添加:

android:horizontalSpacing="0dp" 
android:verticalSpacing="0dp"

【讨论】:

    【解决方案2】:

    您可以使用:android:listSelector 进行更改。

    您可以尝试使用 android:listSelector="@null

    删除选择器
    <!-- Setting the listSelector to null removes the 5px border -->
    <GridView
    android:id="@+id/gridview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:listSelector="@null" />
    

    如果它不起作用,请将 android:fadingEdgeLength="0px" 添加到您的 GridView

    <GridView
    android:id="@+id/gridview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:fadingEdgeLength="0px"
    android:listSelector="@null" />
    

    或者,在 Java 中:

    GridView.setFadingEdgeLength(0);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多