Example usage for android.view.animation TranslateAnimation TranslateAnimation

List of usage examples for android.view.animation TranslateAnimation TranslateAnimation

Introduction

In this page you can find the example usage for android.view.animation TranslateAnimation TranslateAnimation.

Prototype

public TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) 

Source Link

Document

Constructor to use when building a TranslateAnimation from code

Usage

From source file:com.timecontents.smartnotice.animate.AnimatedListViewAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (position > _objects.size()) {
        return null;
    }/*from   ww  w  .  ja  va2 s  . c  o m*/

    View v = convertView;
    ViewHolder holder;
    if (v == null) {
        v = _inflater.inflate(_resourceId, parent, false);

        holder = new ViewHolder();
        holder.tvTitle = (TextView) v.findViewById(R.id.tv_notice_title);
        holder.tvDate = (TextView) v.findViewById(R.id.tv_notice_date);
        holder.tvContent = (LinkEllipseTextView) v.findViewById(R.id.tv_notice_content_ellipse);
        holder.imgContent = (ImageView) v.findViewById(R.id.img_notice_content);
        holder.imgFileIcon = (ImageView) v.findViewById(R.id.img_notice_file_icon);
        holder.imgType = (ImageView) v.findViewById(R.id.img_notice_type_icon); // ? ?  ?

        v.setTag(holder);
    } else
        holder = (ViewHolder) v.getTag();

    JSONObject object = _objects.get(position);
    _objectMapper.bindObjectToView(object, holder, v);

    if (v != null) {
        Animation animation = new TranslateAnimation(0, 0, (position > lastPosition) ? 100 : -100, 0);
        animation.setDuration(400);
        v.startAnimation(animation);
    }
    lastPosition = position;

    return v;
}

From source file:freed.cam.ui.themesample.cameraui.HelpFragment.java

private void showOpenSettingsMenu() {
    TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f, 0.0f, 0.0f);
    animation.setDuration(1000);/*from  w ww  .j a  v a 2 s. c  om*/
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.INFINITE);
    animation.setFillAfter(true);
    finger.startAnimation(animation);
    description.setText("Swipe from left to right to open Settings");
}

From source file:pl.wasat.smarthma.customviews.EntryItemView.java

private void titleAnimation() {
    String title = this.entry.getTitle().replaceFirst("urn:ogc:def:", "");
    if (title.length() < 30) {
        tvEntryTitle.setText(title);//w w  w  .ja v  a2s .  c om
        return;
    }

    int stopAnimPos = -1000;
    int startAnimPos = 20;
    int duration = 30000;

    Animation animation = new TranslateAnimation(startAnimPos, stopAnimPos, 0, 0);
    animation.setDuration(duration);
    animation.setRepeatMode(Animation.RESTART);
    animation.setRepeatCount(Animation.INFINITE);
    animation.setAnimationListener(this);

    tvEntryTitle.setText(title);
    tvEntryTitle.measure(0, 0);
    tvEntryTitle.setAnimation(animation);
}

From source file:freed.cam.ui.themesample.cameraui.HelpFragment.java

private void showCloseSettingsMenu() {
    TranslateAnimation animation = new TranslateAnimation(400.0f, 0.0f, 0.0f, 0.0f);
    animation.setDuration(1000);/*from w  ww.  j  a  v a  2 s  .c o  m*/
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.INFINITE);
    animation.setFillAfter(true);
    finger.startAnimation(animation);
    description.setText("Swipe from right to left to close Settings");
}

From source file:com.geekandroid.sdk.ClearEditText.java

/**
 * /*from   ww  w. j av  a  2  s. c om*/
 * @param counts 1
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(1000);
    return translateAnimation;
}

From source file:cn.eoe.wiki.view.SliderLayer.java

public void openSidebar(int index) {
    if (index <= mOpenLayerIndex) {
        L.e("index must greater than the opening layer index");
        return;//from   w  w w . jav a  2 s .c om
    }
    if (index > mListLayers.size()) {
        L.e("index must less than the max layer index:" + mListLayers.size());
        return;
    }
    SliderEntity layer = mListLayers.get(index);
    if (layer.view.getAnimation() != null) {
        return;
    }
    // View belowLayer = getBelowLayerView(index);
    L.d("try to open:" + index);
    mAnimation = new TranslateAnimation(0, -(layer.closeX - layer.openX), 0, 0);
    mAnimation.setAnimationListener(new OpenListener(layer.view));

    mAnimation.setDuration(DURATION);
    mAnimation.setFillAfter(true);
    mAnimation.setFillEnabled(true);

    mOpenLayerIndex = index;
    layer.view.startAnimation(mAnimation);
}

From source file:freed.cam.ui.themesample.cameraui.HelpFragment.java

private void showOpenManualMenu() {
    TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 400.0f, 0.0f);
    animation.setDuration(1000);//from  ww w  . j  a  v  a 2s  .co  m
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.INFINITE);
    animation.setFillAfter(true);
    finger.startAnimation(animation);
    description.setText("Swipe from bottom to top to open Manuals");
}

From source file:com.geecko.QuickLyric.utils.ScreenSlidePagerAdapter.java

public void exitAction() {
    Animation slideOut = new TranslateAnimation(0f, -2000f, 0f, 0f);
    slideOut.setInterpolator(new AccelerateInterpolator());
    slideOut.setDuration(700);//from www .j a  v a  2  s.c  o m

    slideOut.setAnimationListener(new Animation.AnimationListener() {
        public void onAnimationEnd(Animation animation) {
            ((RelativeLayout) mPager.getParent()).setVisibility(View.GONE);
            ((MainActivity) mActivity).focusOnFragment = true;
            if (((MainActivity) mActivity).mDrawerToggle != null) {
                ((MainActivity) mActivity).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                ((MainActivity) mActivity).mDrawerToggle.setDrawerIndicatorEnabled(true);
            }
            mActivity.invalidateOptionsMenu();
            SharedPreferences.Editor editor = mActivity.getSharedPreferences("tutorial", Context.MODE_PRIVATE)
                    .edit();
            editor.putBoolean("seen", true);
            editor.apply();
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
        }
    });
    ((MainActivity) mActivity).setStatusBarColor(null);
    ((MainActivity) mActivity).setNavBarColor(null);
    ((RelativeLayout) mPager.getParent()).startAnimation(slideOut);
}

From source file:com.givon.baseproject.xinlu.fragment.FraHome.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = getActivity().getLayoutInflater().inflate(R.layout.layout_frahome, null);
    mRefreshableView = (RefreshableView) view.findViewById(R.id.refreshable_view);
    mRefreshableView.setRefreshListener(this);
    mTopBarLayout = (LinearLayout) view.findViewById(R.id.ly_top_bar);
    mTv_SearchView = (TextView) view.findViewById(R.id.tv_search);
    mTv_SearchView.setOnClickListener(this);
    mTopBarLayout_Jiadi = (LinearLayout) view.findViewById(R.id.ly_top_bar_jiadi);
    mDotPager = (TopDotPager) view.findViewById(R.id.topDotPager);
    mDotPager.setmBitmapUtils(new BitmapUtils(getActivity()));
    mMyScrollView = (MyScrollView) view.findViewById(R.id.sv_ScrollView);
    InitWidth(view);//from ww  w . java  2 s  .c o m
    InitTextView(view);
    InitViewPager(view);
    resources = getResources();
    TranslateAnimation animation = new TranslateAnimation(position_one, offset, 0, 0);
    tvTabHot.setTextColor(resources.getColor(R.color.font_white));
    animation.setFillAfter(true);
    animation.setDuration(300);
    ivBottomLine.startAnimation(animation);
    return view;
}

From source file:quickbeer.android.next.views.ProgressIndicatorBar.java

private void animateScroller() {
    Log.v(TAG, "animateScroller()");

    int animEnd = getWidth() - progressBarWidth;

    TranslateAnimation animation = new TranslateAnimation(0, animEnd, 0, 0);
    animation.setDuration(ANIMATION_SCROLL_DURATION);
    animation.setFillAfter(true);//  w ww. j  a va 2 s.c o m
    animation.setRepeatMode(Animation.REVERSE);
    animation.setRepeatCount(Animation.INFINITE);
    animation.setAnimationListener(new Animation.AnimationListener() {
        private int repeatCounter = 0;

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            if (++repeatCounter % 2 == 0 && nextStatus != Status.INDEFINITE) {
                applyNextStatus();
            }
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}