我有几个三星设备(GT-I9192/4.2.2、GT-I9295/4.2.2 等)用于测试目的,所有这些设备都不会显示 HorisontalScrollView 的渐变边缘。所有其他智能手机,如 HTC、摩托罗拉、魅族等(主要是 aos 4.x,有几个是 2.3.5)很好地显示了渐变边缘。
因为在 api14 中添加了新属性 android:requiresFadingEdge
它没有替代代码(至少我没有找到它)我使用以下布局(此滚动用于选项卡滚动):
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabs_horisontal_scroll_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:fadingEdge="horizontal"
android:fadingEdgeLength="32dp"
android:fillViewport="true"
android:layerType="software" //was thinking it might help but it doesn't
android:requiresFadingEdge="horizontal"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbars="none" />
就像我说过的,在任何智能手机上一切正常,但在三星手机上却不行。实际上,三星设备确实绘制了 fadingEdge,它在所有三星设备上看起来都一样,但看起来最大宽度为 2-3px。所以我注意到它绘制了它而不是 32dp 并且它忽略了有关 FadingEdge 设置的所有内容。可能唯一的关闭是工作正常。
那么可能是什么问题?
最佳答案
尝试使用 android:overScrollMode
属性。
只需添加
android:overScrollMode="always"
到您的 HorizontalScrollView
。
android:overScrollMode can have three values: "always", "never", "ifContentScrolls".
关于Android setHorizontalFadingEdgeEnabled 不适用于三星,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21292569/