this should get you started. Override your ListView like so:
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;
}
in getChildStaticTransformation you can achieve various effects (even 3d) by manipulating the matrix accordingly.
A very good tutorial (which uses another technique can be found here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…