List of usage examples for android.view.animation TranslateAnimation setDuration
public void setDuration(long durationMillis)
From source file:net.bither.fragment.hot.MarketFragment.java
public void showPriceAlertAnimTo(int fromX, int fromY, Market toMarket) { int[] containerOffset = new int[2]; v.getLocationInWindow(containerOffset); containerOffset[0] += v.getPaddingLeft(); containerOffset[1] += v.getPaddingTop(); ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) ivMarketPriceAnimIcon.getLayoutParams(); lp.topMargin = fromY - containerOffset[1]; lp.leftMargin = fromX - containerOffset[0]; int marketIndex = markets.indexOf(toMarket); if (marketIndex < lv.getFirstVisiblePosition() || marketIndex > lv.getLastVisiblePosition()) { lv.setSelection(marketIndex);/* w w w . j a v a2s. co m*/ } View marketView = lv.getChildAt(marketIndex - lv.getFirstVisiblePosition()); View toIconView = marketView.findViewById(R.id.iv_price_alert); int[] toLocation = new int[2]; toIconView.getLocationInWindow(toLocation); TranslateAnimation anim = new TranslateAnimation(0, toLocation[0] - fromX, 0, toLocation[1] - fromY); anim.setDuration(300); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { doRefresh(); ivMarketPriceAnimIcon.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); ivMarketPriceAnimIcon.setVisibility(View.VISIBLE); ivMarketPriceAnimIcon.startAnimation(anim); }
From source file:ezy.ui.view.NoticeView.java
private Animation anim(float from, float to) { final TranslateAnimation anim = new TranslateAnimation(0, 0f, 0, 0f, Animation.RELATIVE_TO_PARENT, from, Animation.RELATIVE_TO_PARENT, to); anim.setDuration(mDuration); anim.setFillAfter(false);/*from w ww. j a v a2s. co m*/ anim.setInterpolator(new LinearInterpolator()); return anim; }
From source file:gov.whitehouse.ui.activities.BaseDashboardActivity.java
public void hideSearch() { final int height = mSearchFragment.getView().getHeight(); TranslateAnimation slideUpAnim = new TranslateAnimation(0, 0, 0, -height); slideUpAnim.setDuration(SEARCH_FRAGMENT_ANIMATION_DURATION); slideUpAnim.setAnimationListener(new Animation.AnimationListener() { @Override//w w w . j a va2 s. c om public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { getSupportFragmentManager().beginTransaction().hide(mSearchFragment).commitAllowingStateLoss(); mSearchField.setText(""); mSearchField.clearFocus(); mDrawerGarment.setDrawerEnabled(true); } @Override public void onAnimationRepeat(Animation animation) { } }); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mSearchFragment.getView().startAnimation(slideUpAnim); mShowingSearch = false; }
From source file:gov.whitehouse.ui.activities.BaseDashboardActivity.java
public void showSearch() { final int height = mSearchFragment.getView().getHeight(); TranslateAnimation slideDownAnim = new TranslateAnimation(0, 0, -height, 0); slideDownAnim.setDuration(SEARCH_FRAGMENT_ANIMATION_DURATION); slideDownAnim.setAnimationListener(new Animation.AnimationListener() { @Override/*w ww .j av a 2 s . c om*/ public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { getSupportFragmentManager().beginTransaction().show(mSearchFragment).commitAllowingStateLoss(); mSearchFragment.getView().requestLayout(); mDrawerGarment.setDrawerEnabled(false); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); if (!mSearchField.getText().toString().equals("")) { mSearchFragment.setListShown(true); mSearchFragment.doSearchForQuery(mSearchField.getText().toString()); } } @Override public void onAnimationRepeat(Animation animation) { } }); mSearchFragment.getView().startAnimation(slideDownAnim); mShowingSearch = true; }
From source file:us.shandian.blacklight.ui.statuses.TimeLineFragment.java
@Override public boolean onTouch(View v, MotionEvent ev) { switch (ev.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mLastY = ev.getY();/* w w w. j a v a 2 s .c o m*/ break; case MotionEvent.ACTION_MOVE: if (mLastY == -1.0f) break; float y = ev.getY(); if (!mNewHidden && y < mLastY) { mNew.clearAnimation(); TranslateAnimation anim = new TranslateAnimation(0, 0, 0, mList.getHeight() - mNew.getTop()); anim.setFillAfter(true); anim.setDuration(400); mNew.setAnimation(anim); anim.startNow(); mNewHidden = true; } else if (mNewHidden && y > mLastY) { mNew.clearAnimation(); TranslateAnimation anim = new TranslateAnimation(0, 0, mList.getHeight() - mNew.getTop(), 0); anim.setFillAfter(true); anim.setDuration(400); mNew.setAnimation(anim); anim.startNow(); mNewHidden = false; } mLastY = y; break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mLastY = -1.0f; break; } return false; }
From source file:org.bcsphere.activity.BCPage.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btnManager: mActivity.managerPopupWindow.showAsDropDown(view, 0, 0); TranslateAnimation animation = new TranslateAnimation(0, 0, 0, (float) (getScreenHeight(mActivity) * (430.0 / 1920.0))); animation.setDuration(200); animation.setFillAfter(true);/*from ww w. java 2 s.c o m*/ parentView.startAnimation(animation); break; case R.id.btnMenu: if (menuPopupWindow == null) { menuPopupWindow = new MenuPopupWindow(mActivity); } if (menuPopupWindow.isShowing()) { menuPopupWindow.dismiss(); return; } menuPopupWindow.showAsDropDown(btnMenu, 0, 20); break; case R.id.btnBack: mWebView.goBack(); break; case R.id.btnClose: Intent intent = new Intent(); intent.setAction("removeApp"); intent.putExtra("removeAppURL", PageManager.getCurrentPager().url); mActivity.sendBroadcast(intent); PageManager.setDeleteUrl(PageManager.getCurrentPager().url); break; case R.id.hintOpenBluetooth: startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS)); break; case R.id.hintOpenNetwork: startActivity(new Intent(Settings.ACTION_SETTINGS)); break; } }
From source file:com.example.fragment.ScreenSlidePageFragment.java
public void startAnimation() { // SELECT LAYER ScrollView relate = (ScrollView) mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate; float toX = -8.0f / 100.0f;//0.0f; float fromX = 0.0f;//-8.0f / 100.0f; float toY = 0.0f; float fromY = 29.0f / 100.0f; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(2000); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate);/*from www . j ava 2 s. co m*/ set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:com.jiubai.jiubaijz.zxing.activity.CaptureActivity.java
private void initView() { Window window = getWindow();//from w w w .j a va 2s .c o m window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_capture); ButterKnife.bind(this); mInactivityTimer = new InactivityTimer(this); mBeepManager = new BeepManager(this); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.9f); animation.setDuration(4500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); mScanLineImageView.startAnimation(animation); }
From source file:com.plusub.lib.example.view.TabView.java
/** * ?/* w w w .jav a 2s . co m*/ * @param arg0 */ private void moveCursor(int arg0) { TranslateAnimation animation = new TranslateAnimation(mCursorCurPosition, arg0 * mScreenWidth / tabCount, Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF); mCursorCurPosition = arg0 * mScreenWidth / tabCount; animation.setDuration(200); animation.setInterpolator(new LinearInterpolator()); animation.setFillAfter(true); mIvCursor.startAnimation(animation); }
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);//w w w . ja va 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; }