列表视图行的变化幅度时,滚动旋转木马一样观点的android视图、木马、幅度、观点

由网友(从来没有遇见)分享简介:我想实现的动画列表view.As显示在下面的图片时,列表视图项完全可见当时的变化完全可见项目的其它明智的宽度宽度保持默认宽度为given.Here蓝色项宽度较小时,其不完全可见,但是当进来的屏幕中间的绿色项目,然后它的宽度变为全模式animation.How我可以在列表视图中实现了这一类型的动画?I am tryin...

我想实现的动画列表view.As显示在下面的图片时,列表视图项完全可见当时的变化完全可见项目的其它明智的宽度宽度保持默认宽度为given.Here蓝色项宽度较小时,其不完全可见,但是当进来的屏幕中间的绿色项目,然后它的宽度变为全模式animation.How我可以在列表视图中实现了这一类型的动画?

I am trying to achieved animated list view.As show in below image when list view item fully visible that time change width of fully visible item other wise its width remain default width as given.Here blue color item width is small when its not fully visible but when green color item come in middle of screen then its width goes to full mode with animation.How can i achieved this type of animation in list view ?

改变了未来的产品与动画列表项的大小。

change size of up coming item with animation for list item.

推荐答案

试着用下面的code ...,并更改为适合您。

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;
    }

}
阅读全文

相关推荐

最新文章