Search in sources :

Example 51 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project AndroidStudy by tinggengyan.

the class PullScrollView method rollBackAnimation.

private void rollBackAnimation() {
    TranslateAnimation tranAnim = new TranslateAnimation(0, 0, Math.abs(mInitTop - mCurrentTop), 0);
    tranAnim.setDuration(200);
    mHeader.startAnimation(tranAnim);
    mHeader.layout(mHeader.getLeft(), mInitTop, mHeader.getRight(), mInitBottom);
    // 开启移动动画
    TranslateAnimation innerAnim = new TranslateAnimation(0, 0, mContentView.getTop(), mContentRect.top);
    innerAnim.setDuration(200);
    mContentView.startAnimation(innerAnim);
    mContentView.layout(mContentRect.left, mContentRect.top, mContentRect.right, mContentRect.bottom);
    mContentRect.setEmpty();
    // 回调监听器
    if (mCurrentTop > mInitTop + TURN_DISTANCE && mOnTurnListener != null) {
        mOnTurnListener.onTurn();
    }
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 52 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project AndroidStudy by tinggengyan.

the class MyPopupMenu method divisionTran.

/**
 * 分界线布局中的textView跟随选中标题移动位置的,设置为动画效果
 */
public void divisionTran(int position) {
    /**
     * 先移除了RelativeLayout中原有的textView
     */
    divisionLayout.removeAllViews();
    /**
     * 重新设置textView布局属性 动态改变控件位置 第一步
     */
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(screenWidth / 3, LayoutParams.MATCH_PARENT);
    /**
     * 设置动画效果
     */
    Animation translateTextView;
    translateTextView = new TranslateAnimation((preIndex - currentIndex) * screenWidth / 3, 0, 0, 0);
    /**
     * 根据选中的标题确定布局 动态改变控件位置 第二步
     */
    if (position == 0) {
        lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    } else if (position == 1) {
        lp.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    } else {
        lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    }
    /**
     * 动态改变控件位置 第三步
     */
    TextView line = new TextView(context);
    line.setBackgroundColor(Color.WHITE);
    divisionLayout.addView(line, lp);
    /**
     * 设置动画执行时间
     */
    translateTextView.setDuration(200);
    /**
     * 启动动画
     */
    line.startAnimation(translateTextView);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) TextView(android.widget.TextView)

Example 53 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project MVPFrames by RockyQu.

the class AnimationUtils method getTranslateAnimation.

/**
 * 获取一个移动动画
 *
 * @param fromXDelta        动画起始时 X坐标上的移动位置
 * @param toXDelta          动画结束时 X坐标上的移动位置
 * @param fromYDelta        动画起始时 Y坐标上的移动位置
 * @param toYDelta          动画结束时 Y坐标上的移动位置
 * @param durationMillis    时间
 * @param interpolator      插值器
 *                          AccelerateDecelerateInterpolator 在动画开始与结束的地方速率改变比较慢,在中间的时候加速
 *                          AccelerateInterpolator 在动画开始的地方速率改变比较慢,然后开始加速
 *                          AnticipateInterpolator 开始的时候向后然后向前甩
 *                          AnticipateOvershootInterpolator 开始的时候向后然后向前甩一定值后返回最后的值
 *                          BounceInterpolator 动画结束的时候弹起
 *                          CycleInterpolator 动画循环播放特定的次数,速率改变沿着正弦曲线
 *                          DecelerateInterpolator 在动画开始的地方快然后慢
 *                          LinearInterpolator 以常量速率改变
 *                          OvershootInterpolator  向前甩一定值后再回到原来位置
 * @param animationListener 监听
 * @return 返回一个移动动画
 */
public static TranslateAnimation getTranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long durationMillis, Interpolator interpolator, AnimationListener animationListener) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    translateAnimation.setInterpolator(interpolator);
    translateAnimation.setDuration(durationMillis);
    translateAnimation.setAnimationListener(animationListener);
    return translateAnimation;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 54 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project lzc_app_lib by httplzc.

the class ShowBigImgActivity method showStartAnim.

// 开始动画
private void showStartAnim() {
    BigImgShowData.MessageUri messageUri = bigImgShowData.getData(startPosition).getMessageUri();
    if (messageUri == null) {
        showBigImgViewPagerAdapter.setIsAnim(false);
        return;
    }
    showBigImgViewPagerAdapter.setIsAnim(true);
    AnimationSet animationSet = new AnimationSet(true);
    Animation animation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    // Log.i("lzc","transLateY  "+(messageUri.getCenterX() - ScreenData.widthPX / 2)+"    "+(messageUri.getCenterY() - ScreenData.heightPX/2));
    Animation animationTrans = new TranslateAnimation(messageUri.getCenterX() - ScreenData.widthPX / 2, 0, messageUri.getCenterY() - ScreenData.heightPX / 2, 0);
    animationSet.addAnimation(animation);
    animationSet.addAnimation(animationTrans);
    animationSet.setDuration(aninTime);
    animation.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.setAnimation(animationSet);
    animationSet.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            showBigImgViewPagerAdapter.setIsAnim(false);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    startAlphaAnim();
    animationSet.start();
}
Also used : BigImgShowData(com.yioks.lzclib.Data.BigImgShowData) ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) AnimationSet(android.view.animation.AnimationSet) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 55 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project actor-platform by actorapp.

the class ExplorerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d("Explorer Animation", "Created");
    {
        rootView = inflater.inflate(R.layout.picker_fragment_file_picker, container, false);
        list = (ListView) rootView.findViewById(R.id.list);
        Bundle bundle = getArguments();
        statusView = (TextView) rootView.findViewById(R.id.status);
        emptyView = rootView.findViewById(R.id.empty);
        items = new ArrayList<ExplorerItem>();
        if (bundle != null) {
            path = bundle.getString("path");
            Log.d(LOG_TAG, "Path: " + path);
            File currentPathFile = new File(path);
            File[] fileList = currentPathFile.listFiles();
            title = currentPathFile.getPath();
            if (title.contains(Environment.getExternalStorageDirectory().getPath())) {
                title = title.replace(Environment.getExternalStorageDirectory().getPath(), "");
            }
            if (title.length() > 0 && title.toCharArray()[0] == '/') {
                title = title.substring(1);
            }
            if (path.equals(Environment.getExternalStorageDirectory().getPath())) {
                if (Environment.isExternalStorageEmulated()) {
                    title = getString(R.string.picker_file_memory_phone);
                } else
                    title = getString((R.string.picker_file_memory_external));
            } else if (path.equals("/"))
                title = getString(R.string.picker_file_memory_phone);
            if (fileList == null) {
                statusView.setVisibility(View.VISIBLE);
                File external = Environment.getExternalStorageDirectory();
                if (path.equals(external.getPath()))
                    statusView.setText(R.string.picker_file_memory_external_error);
                else
                    statusView.setText(R.string.picker_file_denied);
                return rootView;
            } else {
                if (fileList.length == 0) {
                    emptyView.setVisibility(View.VISIBLE);
                    AnimationSet slideInAnimation = new AnimationSet(true);
                    slideInAnimation.setInterpolator(new MaterialInterpolator());
                    slideInAnimation.setDuration(280);
                    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
                    slideInAnimation.addAnimation(alphaAnimation);
                    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 150, 0);
                    slideInAnimation.addAnimation(translateAnimation);
                    emptyView.startAnimation(slideInAnimation);
                    statusView.setVisibility(View.VISIBLE);
                    AnimationSet slideInAnimation1 = new AnimationSet(true);
                    slideInAnimation1.setInterpolator(new MaterialInterpolator());
                    slideInAnimation1.setDuration(280);
                    // cause of offset
                    slideInAnimation1.setStartOffset(150);
                    AlphaAnimation alphaAnimation1 = new AlphaAnimation(0, 1);
                    slideInAnimation1.addAnimation(alphaAnimation1);
                    TranslateAnimation translateAnimation1 = new TranslateAnimation(0, 0, 150, 0);
                    slideInAnimation1.addAnimation(translateAnimation1);
                    statusView.startAnimation(slideInAnimation1);
                    statusView.setText(R.string.picker_file_directory_empty);
                // return rootView;
                }
            }
            Log.d(LOG_TAG, "Size: " + fileList.length);
            for (File file : fileList) {
                putItem(file);
            }
            Collections.sort(items, new FileNameOrderComparator());
            insertBack();
            adapter = new ExplorerAdapter(getActivity(), items);
        } else {
            welcome = true;
            // items.add(new StorageItem(getActivity()));
            adapter = new WelcomeExplorerAdapter(getActivity(), items);
            items.add(new HeaderItem(getString(R.string.picker_file_header_main)));
            String externalStorageState = Environment.getExternalStorageState();
            Log.w(LOG_TAG, externalStorageState);
            if (externalStorageState.equals(Environment.MEDIA_REMOVED) || externalStorageState.equals(Environment.MEDIA_BAD_REMOVAL) || externalStorageState.equals(Environment.MEDIA_UNKNOWN) || externalStorageState.equals(Environment.MEDIA_UNMOUNTED) || externalStorageState.equals(Environment.MEDIA_UNMOUNTABLE) || externalStorageState.equals(Environment.MEDIA_SHARED) || externalStorageState.equals(Environment.MEDIA_NOFS)) {
                items.add(new StorageItem(getString(R.string.picker_file_memory_phone)));
            } else {
                /*
                    File cameraFile = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
                    if(cameraFile.exists()) {
                       items.add(new FolderItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),R.drawable.picker_folder_camera,getString(R.string.picker_files_camera)));
                    }*/
                putItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM));
                putItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
                putItem((Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)));
                putItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC));
                putItem((Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)));
                if (Environment.isExternalStorageEmulated()) {
                    items.add(new ExternalStorageItem(getString(R.string.picker_file_memory_phone), R.drawable.picker_memory));
                } else
                    items.add(new ExternalStorageItem(getString(R.string.picker_file_memory_external), R.drawable.picker_sdcard));
                if (Build.VERSION.SDK_INT >= 19) {
                // putItem(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS));
                // even on sdk>19 documents folder does not work.
                }
            }
            path = "";
            title = getString(R.string.picker_file_activity_title);
            ArrayList<ExplorerItem> historyItems = loadHistory();
            if (!historyItems.isEmpty()) {
                items.addAll(historyItems);
            }
        }
        list.setAdapter(adapter);
        list.setOnItemClickListener((BasePickerActivity) getActivity());
    }
    pickerActivity.updateCounter();
    return rootView;
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) TranslateAnimation(android.view.animation.TranslateAnimation) HeaderItem(im.actor.sdk.controllers.pickers.file.items.HeaderItem) AlphaAnimation(android.view.animation.AlphaAnimation) MaterialInterpolator(im.actor.sdk.controllers.pickers.file.view.MaterialInterpolator) ListView(android.widget.ListView) FileNameOrderComparator(im.actor.sdk.controllers.pickers.file.util.FileNameOrderComparator) TextView(android.widget.TextView) File(java.io.File) AnimationSet(android.view.animation.AnimationSet) ExternalStorageItem(im.actor.sdk.controllers.pickers.file.items.ExternalStorageItem) StorageItem(im.actor.sdk.controllers.pickers.file.items.StorageItem) ExternalStorageItem(im.actor.sdk.controllers.pickers.file.items.ExternalStorageItem)

Aggregations

TranslateAnimation (android.view.animation.TranslateAnimation)229 Animation (android.view.animation.Animation)109 AlphaAnimation (android.view.animation.AlphaAnimation)90 AnimationSet (android.view.animation.AnimationSet)69 ScaleAnimation (android.view.animation.ScaleAnimation)44 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)27 View (android.view.View)22 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)22 TextView (android.widget.TextView)18 AnimationListener (android.view.animation.Animation.AnimationListener)17 LinearInterpolator (android.view.animation.LinearInterpolator)13 RotateAnimation (android.view.animation.RotateAnimation)13 ClipRectAnimation (android.view.animation.ClipRectAnimation)12 ListView (android.widget.ListView)12 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)12 ImageView (android.widget.ImageView)11 LayoutAnimationController (android.view.animation.LayoutAnimationController)8 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)8 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)8