【问题标题】:remove blue glow around ListItem in ListView (android)移除 ListView 中 ListItem 周围的蓝色光晕(android)
【发布时间】:2013-02-25 19:53:45
【问题描述】:

我想在单击列表项时摆脱这种可怕的蓝色 HOLO 光晕。

我有:

<ListView
        android:id="@+id/projects_list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:cacheColorHint="#00000000"
        android:choiceMode="singleChoice"
        android:listSelector="@android:color/transparent"
        android:paddingBottom="0dp"
        android:paddingLeft="0dp"
        android:paddingRight="0dp"
        android:scrollbars="none" />

但它仍然看起来像这样: http://www.roji.be/IMG_0001.png

更新: 好的,我的应用是:

<style name="AppBaseTheme" parent="android:style/Theme.Light">
<item name="android:actionBarStyle">@style/ActionBar</item>
        <item name="android:windowBackground">@drawable/gradient_bg</item>
        <item name="android:windowContentOverlay">@null</item>
</style>

每个列表项都被包裹在一个 LinearLayout 中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.axxes.netinc"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/listitemshadow" //9patch shadow 
    android:orientation="vertical"
    android:paddingTop="8dp" >

【问题讨论】:

  • 我无法用上面的代码复制你的问题。问题一定出在其他地方。您是否为自定义列表视图使用自定义选择器??
  • 我更新了这个问题,我认为它可能与按下项目时列表项的背景有关(因为我应用填充以获得列表项之间的间距)

标签: android eclipse listview layout


【解决方案1】:

将列表视图的淡入淡出边缘设置为无。

<ListView
    android:id="@+id/projects_list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:cacheColorHint="#00000000"
    android:choiceMode="singleChoice"
    android:listSelector="@android:color/transparent"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:scrollbars="none"
    android:fadingEdge="none" />

【讨论】:

  • 我将自己的幻灯片监听器添加到 baseadaptor 并手动调用 onitemselected 并设置 v.setPressed(true);所以选择器会选择它。现在我没有边界了
【解决方案2】:

彻底消除蓝光:

android:overScrollMode="never" 将此属性放在列表视图中。
要更改发光颜色,请在应用程序类中添加此代码

int glowDrawableId = getResources().getIdentifier("overscroll_glow", "drawable", "android");
        int edgeDrawableId = getResources().getIdentifier("overscroll_edge", "drawable", "android");
        Drawable androidGlow = ContextCompat.getDrawable(this, glowDrawableId);
        Drawable androidEdge = ContextCompat.getDrawable(this, edgeDrawableId);
        androidGlow.setColorFilter(getResources().getColor(R.color.white_20), PorterDuff.Mode.SRC_IN);
        androidEdge.setColorFilter(getResources().getColor(R.color.white_20), PorterDuff.Mode.SRC_IN);

【讨论】:

    【解决方案3】:

    只需在您的列表视图中添加android:overScrollMode="never"

            <ListView
                android:layout_marginTop="5dp"
                android:id="@+id/listview"
                tools:listitem="@layout/row_item"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:overScrollMode="never">
            </ListView>
    

    【讨论】:

      猜你喜欢
      • 2012-03-06
      • 2021-04-26
      • 2018-07-28
      • 1970-01-01
      • 1970-01-01
      • 2011-08-28
      • 2014-05-09
      • 1970-01-01
      • 2021-07-08
      相关资源
      最近更新 更多