ListView分隔线的默认颜色是什么?

Eth*_*len 29 android android-listview

目前我正在使用此代码查看分隔线:

medalsList.setDivider(new ColorDrawable(0x99F10529));
medalsList.setDividerHeight(1);
Run Code Online (Sandbox Code Playgroud)

在没有更改分隔线的ListView上使用的默认RGB颜色(如上面的代码所示)是什么?

Ted*_*opp 38

默认分隔符由listDivider当前主题中的项目确定.对于股票主题,默认分隔符是以下之一:

  • android:drawable/divider_horizo​​ntal_dark(主题)
  • android:drawable/divider_horizo​​ntal_bright(Theme.Light)
  • android:drawable/divider_horizo​​ntal_holo_dark(Theme.Holo)
  • android:drawable/divider_horizo​​ntal_holo_light(Theme.Holo.Light)

这些drawable可以在sdk安装的platform data文件夹中找到.


小智 24

您可以使用:

<View
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="?android:attr/listDivider" />
Run Code Online (Sandbox Code Playgroud)

请参阅:如何获取默认分频器?

PS在这里发布,因为谷歌搜索似乎首先在这个线程而不是另一个线程上.