繁体   English   中英

Android ListView:糟糕的渐变分割器

[英]Android ListView : bad gradient divider

我有一个ListView:

<ListView
    android:id="@+id/mainList"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_marginLeft="1dip"
    android:layout_marginRight="1dip"
    android:divider="@drawable/list_divider"
    android:dividerHeight="1px"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:cacheColorHint="#00000000"
/>

和list_divider.xml中的形状

<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">
   <gradient
      android:startColor="#00000000"
      android:centerColor="#FFFFFFFF"
      android:endColor="#00000000"
      android:angle="0" />
</shape>

但不是像这样的分隔物:白色 - 灰色 - 黑色 - 灰色 - 白色
我明白了:白色 - 灰色 - 黑色 - 灰色 - 白色 - 灰色 - 黑色 - 灰色 - 白色???
简而言之,分隔器被分成两个相似的部分,我只需要一个。

对于渐变白灰黑色 - 灰白色使用:

<gradient
   android:startColor="#ffffff"
   android:centerColor="#000000"
   android:endColor="#ffffff"
   android:angle="0">

双梯度可能是由于您添加到颜色的Alpha通道。 例如,中心颜色以#00 (8字节)开头,表示完全透明,因此您具有底层颜色。

我稍微改变了渐变。 对某些人来说可能有用。

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
  <gradient
      android:startColor="#E4E4E4"
      android:centerColor="#F0F0F0"
      android:endColor="#E4E4E4"
      android:angle="90" />
</shape>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM