gpt4 book ai didi

Android ListView 分隔符

转载 作者:IT老高 更新时间:2023-10-28 13:05:26 24 4
gpt4 key购买 nike

我有这个代码:

<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cashItemsList"
android:cacheColorHint="#00000000"
android:divider="@drawable/list_divider"></ListView>

@drawable/list_divider 是:

<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#8F8F8F"
android:dashWidth="1dp"
android:dashGap="1dp" />
</shape>

但我看不到任何分隔线。

最佳答案

伙计们,这就是为什么您应该使用 1px 而不是 1dp 或 1dip:如果您指定 1dp 或 1dip,Android 会按比例缩小。在 120dpi 的设备上,它变成了 0.75px 的平移量,四舍五入为 0。在某些设备上,它转换为 2-3 像素,通常看起来很难看或草率

对于分隔线,如果您想要一个 1 像素的分隔线,1px 是正确的高度,并且是“一切都应该倾斜”规则的异常(exception)之一。在所有屏幕上都是 1 个像素。另外,1px 通常在 hdpi 及以上的屏幕上看起来更好

“不再是 2012 年”编辑:您可能必须从某个屏幕密度开始切换到 dp/dip

关于Android ListView 分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3979218/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com