Seb*_*wak 8 android scrollview fading
默认情况下,只有可以在该方向上滚动时,scrollview的渐变边缘才可见.我怎样才能让它随时可见?
我不想把任何抽签放在上面或类似的东西.我想使用内置的淡化边缘来完成它,可能是通过覆盖一些scrollview函数.
提前致谢
cdh*_*ker 23
是的,扩展ScrollView并覆盖这些方法(基于Donut-release2):
@Override
protected float getTopFadingEdgeStrength() {
if (getChildCount() == 0) {
return 0.0f;
}
return 1.0f;
}
@Override
protected float getBottomFadingEdgeStrength() {
if (getChildCount() == 0) {
return 0.0f;
}
return 1.0f;
}
Run Code Online (Sandbox Code Playgroud)
为了比较,这是原始代码,当你接近列表的末尾时缩短了衰落边缘:
@Override
protected float getTopFadingEdgeStrength() {
if (getChildCount() == 0) {
return 0.0f;
}
final int length = getVerticalFadingEdgeLength();
if (mScrollY < length) {
return mScrollY / (float) length;
}
return 1.0f;
}
@Override
protected float getBottomFadingEdgeStrength() {
if (getChildCount() == 0) {
return 0.0f;
}
final int length = getVerticalFadingEdgeLength();
final int bottomEdge = getHeight() - mPaddingBottom;
final int span = getChildAt(0).getBottom() - mScrollY - bottomEdge;
if (span < length) {
return span / (float) length;
}
return 1.0f;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10881 次 |
| 最近记录: |