列表视图行的变化幅度时,滚动旋转木马一样观点的android [英] list view with change width of row when scroll like Carousel view android

查看:143
本文介绍了列表视图行的变化幅度时,滚动旋转木马一样观点的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现的动画列表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;
    }

}

这篇关于列表视图行的变化幅度时,滚动旋转木马一样观点的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆