android – carousel视图实现,如listview滚动
作者:互联网
有人像下面的旋转木马一样实施了吗?
注意:不应重复项目列表,在到达最后一项后不应先到达.请帮帮我.
[编辑]
我不想为此使用ListView.
有人帮我这个.谢谢…
解决方法:
这应该让你开始.像这样覆盖ListView:
private final Transformation mTransformation;
public ListView3d(Context context, AttributeSet attrs) {
super(context, attrs);
if (!isInEditMode()) {
setStaticTransformationsEnabled(true);
mTransformation = new Transformation();
mTransformation.setTransformationType(Transformation.TYPE_MATRIX);
} else {
mTransformation = null;
}
}
@Override
protected boolean getChildStaticTransformation(View child, Transformation t) {
mTransformation.getMatrix().reset();
final int childTop = Math.max(0,child.getTop());
final int parentHeight = getHeight();
final float scale = (float)(parentHeight-(childTop/2))/getHeight();
Log.i("scale",scale+"");
final float px = child.getLeft() + (child.getWidth()) / 2;
final float py = child.getTop() + (child.getHeight()) / 2;
mTransformation.getMatrix().postScale(scale, scale, px, py);
t.compose(mTransformation);
return true;
}
在getChildStaticTransformation中,您可以通过相应地操作矩阵来实现各种效果(甚至是3d).
一个非常好的教程(使用另一种技术可以找到here.
标签:android,carousel,android-custom-view 来源: https://codeday.me/bug/20191002/1842672.html