Try with the below code... and make the changes to suite you.
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.animation.Transformation;
import android.widget.ListView;
public class MyListView extends ListView {
private final Transformation mTransformation;
public MyListView(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();
// Log.d("details1","childTop : "+childTop+" , parentHeight : "+parentHeight );
final float scale = (float)(parentHeight-(childTop/2))/getHeight();
// Log.d("details2", "parentHeight-(childTop/2) : "+ (parentHeight-(childTop/2)) );
// Log.d("details3", "getHeight() : "+getHeight());
// Log.d("scale",scale+"");
final float px = child.getLeft() + (child.getWidth()) / 2;
final float py = (child.getTop() + (child.getHeight()) / 2);
// Log.d("details4", "child.getLeft() : "+child.getLeft()+ ", child.getWidth(): "+child.getWidth()+" , child.getTop(): "+child.getTop()+" , child.getHeight()"+child.getHeight());
// Log.d("px py", px +" , "+py);
// Log.e("end", "end");
mTransformation.getMatrix().preScale(scale, scale);
t.compose(mTransformation);
return true;
}
}