List of usage examples for android.view.animation TranslateAnimation TranslateAnimation
public TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
From source file:com.example.haber.ui.activity.TabbedActivity.java
private void addListener() { mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override/* w ww . j a va 2 s . c o m*/ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { LogUtil.i(TAG, "PageScrolled" + position + " " + positionOffset + " " + positionOffsetPixels); } @Override public void onPageSelected(int position) { LogUtil.i(TAG, "PageSelected" + position + " "); } @Override public void onPageScrollStateChanged(int state) { LogUtil.i(TAG, "PageScrollStateChanged " + state); } }); ibHangUp.setOnClickListener(onClickListener); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } private int preIndex = 0; @Override public void onPageSelected(int position) { Animation animation = new TranslateAnimation(preIndex * (displayWidth / 3), position * (displayWidth / 3), 0, 0); animation.setDuration(200); animation.setFillAfter(true); tvLine.startAnimation(animation); preIndex = position; } @Override public void onPageScrollStateChanged(int state) { } }); btnPanZoomOut.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "zoom_out", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanZoomIn.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "zoom_in", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanRight.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "right", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanLeft.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "left", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanUp.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "up", -1); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); break; } return true; } }); btnPanDown.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: PanBiz.newInstance().movePan(getPtzcam_idx(), "down", -1); LogUtil.i(TAG, "DOWN"); break; case MotionEvent.ACTION_UP: PanBiz.newInstance().movePan(getPtzcam_idx(), "stop", -1); LogUtil.i(TAG, "STOP"); break; } return true; } }); }
From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java
/** * Hides the name error textview./*from www .j av a 2 s . c o m*/ */ private void hideNameError() { mNameErrorState = 0; // Re-enable the positive button of the dialog iif the name is also valid setFormIsValidated(mEmailErrorState == 0); if (mNameErrorTextView.getVisibility() == View.GONE) { return; // No need to animate out the textview, it's already gone } AnimationSet fadeOutSet = new AnimationSet(true); fadeOutSet.addAnimation(new AlphaAnimation(1f, 0f)); fadeOutSet.addAnimation(new TranslateAnimation(0f, 0f, 0f, -mErrorAnimTranslateY)); fadeOutSet.setDuration(300); fadeOutSet.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { // Don't care } @Override public void onAnimationEnd(Animation animation) { mNameErrorTextView.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { // Don't care } }); mNameErrorTextView.startAnimation(fadeOutSet); }
From source file:com.app.jdy.ui.RegirsterActivity.java
/** * //from ww w . j ava 2 s . c om * @author zhoufeng * @createtime 2015-1-13 ?6:29:17 * @Decription ? * */ public void initAnimation() { // ? PropertyValuesHolder pvh = PropertyValuesHolder.ofFloat("translationY", 3000f, 0f); ObjectAnimator.ofPropertyValuesHolder(get_regirster_code, pvh).setDuration(animatorStart).start(); ObjectAnimator.ofPropertyValuesHolder(new_username, pvh).setDuration(animatorStart).start(); // ? ObjectAnimator.ofFloat(regirster_code, "translationY", 3000f, 0f).setDuration(animatorStart + 200).start(); ObjectAnimator.ofFloat(new_password, "translationY", 3000f, 0f).setDuration(animatorStart + 400).start(); ObjectAnimator.ofFloat(pwdEye, "translationY", 3000f, 0f).setDuration(animatorStart + 400).start(); Animation translateAnimation7 = new TranslateAnimation(0, 0, 3000f, 0f); translateAnimation7.setDuration(animatorStart + 600);// ? // ? ObjectAnimator.ofFloat(sumbit_regirster, "translationY", 3000f, 0f).setDuration(animatorStart + 800) .start(); }
From source file:com.google.android.apps.santatracker.games.matching.MemoryMatchFragment.java
/** * Load and initialise all animations required for the game. *//*w ww . j a v a 2 s.c o m*/ private void loadAnimations() { mAnimationTimerAlpha = new AlphaAnimation(0.0f, 1.0f); mAnimationTimerAlpha.setDuration(1000); mAnimationTimerAlpha.setRepeatMode(Animation.REVERSE); mAnimationTimerAlpha.setRepeatCount(Animation.INFINITE); mAnimationPlayAgainBackground = AnimationUtils.loadAnimation(getActivity(), R.anim.play_again_bkgrd_anim); mAnimationPlayAgainBackground.setFillAfter(true); mAnimationPlayAgainBackground.setAnimationListener(this); mAnimationCardCover = AnimationUtils.loadAnimation(getActivity(), R.anim.card_answer_flash); mAnimationCardCover.setFillAfter(true); mAnimationPlayAgainMain = AnimationUtils.loadAnimation(getActivity(), R.anim.play_again_main_anim); mAnimationPlayAgainMain.setFillAfter(true); mAnimationPlayAgainMain.setAnimationListener(this); // Special bonus animation to play if the player is particularly awesome. mAnimationSetSnowman = new AnimationSet(true); mAnimationSnowman = new TranslateAnimation(150, 0, 150, 0); mAnimationSnowman.setDuration(1000); mAnimationSetSnowman.addAnimation(mAnimationSnowman); mAnimationSnowmanBack = new TranslateAnimation(0, 150, 0, 150); mAnimationSnowmanBack.setDuration(1000); mAnimationSnowmanBack.setStartOffset(1500); mAnimationSnowmanBack.setAnimationListener(this); mAnimationSetSnowman.addAnimation(mAnimationSnowmanBack); mAnimationSetSnowman.setAnimationListener(this); mAnimationRightPaneSlideOut = AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_out_right); mAnimationRightPaneSlideOut.setFillAfter(true); mAnimationLeftPaneSlideOut = AnimationUtils.loadAnimation(getActivity(), R.anim.left_pane_slide_out); mAnimationLeftPaneSlideOut.setFillAfter(true); mAnimationLeftPaneSlideIn = AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_in_left); mAnimationLeftPaneSlideIn.setFillAfter(true); mAnimationRightPaneSlideIn = AnimationUtils.loadAnimation(getActivity(), R.anim.right_pane_slide_in); mAnimationRightPaneSlideIn.setFillAfter(true); mAnimationScaleLevelDown = AnimationUtils.loadAnimation(getActivity(), R.anim.scale_level_anim_down); mAnimationScaleLevelDown.setAnimationListener(this); mAnimationLevelFadeOut = AnimationUtils.loadAnimation(getActivity(), R.anim.level_fade_out_anim); mAnimationLevelFadeOut.setAnimationListener(this); mAnimationLevelScaleUp = AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up_level_anim); mAnimationLevelScaleUp.setAnimationListener(this); mAnimationRightPaneSlideOut.setAnimationListener(this); mAnimationLeftPaneSlideOut.setAnimationListener(this); }
From source file:com.umeng.comm.ui.fragments.BaseFeedsFragment.java
/** * Float button</br>// w w w . jav a2 s .co m * * @param show or ? */ private void executeAnimation(final boolean show) { if (isExecutingAnim || (show && currentStatus == STATUS_SHOW) || (!show && currentStatus == STATUS_DISMISS)) { return; } isExecutingAnim = true; int moveDis = ((FrameLayout.LayoutParams) (mPostBtn.getLayoutParams())).bottomMargin + mPostBtn.getHeight(); Animation animation = null; if (show) { animation = new TranslateAnimation(0, 0, moveDis, 0); } else { animation = new TranslateAnimation(0, 0, 0, moveDis); } animation.setDuration(300); animation.setFillAfter(true); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { isExecutingAnim = false; if (show) { currentStatus = STATUS_SHOW; } else { currentStatus = STATUS_DISMISS; } // 3.0???????Float // Button?layout? mPostBtn.setClickable(show); } }); mPostBtn.startAnimation(animation); }
From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java
/** * Shows the email error textfield with the appropriate * error message.// w w w. j a va2 s . c o m * * @param message The error message to show */ private void showEmailError(CharSequence message, int errState) { mEmailErrorTextView.setText(message); mEmailErrorState = errState; // Disable the positive button of the dialog setFormIsValidated(false); if (mEmailErrorTextView.getVisibility() == View.VISIBLE) { return; // No need to animate in the textview, it's already visible } mEmailErrorTextView.setVisibility(View.VISIBLE); AnimationSet fadeInSet = new AnimationSet(true); fadeInSet.addAnimation(new AlphaAnimation(0f, 1f)); fadeInSet.addAnimation(new TranslateAnimation(0f, 0f, -mErrorAnimTranslateY, 0f)); fadeInSet.setDuration(300); mEmailErrorTextView.startAnimation(fadeInSet); }
From source file:xj.property.activity.HXBaseActivity.ChatActivity.java
private void showPopWindow2() { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View mMenuView = inflater.inflate(R.layout.unservice_time, null); ((TextView) mMenuView.findViewById(R.id.tv_unservicetime)).setText("?" + MainActivity.startTime + "-" + MainActivity.endTime + "????"); ((TextView) mMenuView.findViewById(R.id.tv_unservicetime)) .setTextSize(getResources().getDimension(R.dimen.tv_unservicetime)); final PopupWindow popupWindow = new PopupWindow(); // ?// w w w .j a v a2 s . c o m // SelectPicPopupWindowView popupWindow.setContentView(mMenuView); // SelectPicPopupWindow popupWindow.setWidth(LinearLayout.LayoutParams.MATCH_PARENT); // SelectPicPopupWindow popupWindow.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); // SelectPicPopupWindow? // this.setFocusable(true); // SelectPicPopupWindow // popupWindow.setAnimationStyle(R.style.AnimTop); TranslateAnimation translateAnimation = new TranslateAnimation(0, 0.0f, 0, 200f); translateAnimation.setDuration(2000); translateAnimation.setFillAfter(true); ((TextView) mMenuView.findViewById(R.id.tv_unservicetime)).setAnimation(translateAnimation); translateAnimation.start(); // ColorDrawable?? ColorDrawable dw = new ColorDrawable(0xb0000000); // SelectPicPopupWindow // mMenuViewOnTouchListener?????? new Handler().postDelayed(new Runnable() { @Override public void run() { // ,Animation.RELATIVE_TO_SELF,10f,Animation.RELATIVE_TO_SELF,10f popupWindow.showAsDropDown(findViewById(R.id.top_bar)); //popupWindow.showAtLocation(findViewById(R.id.list),Gravity.NO_GRAVITY,0,0); } }, 200); }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentSearch.java
private void searchFood(final String item, final int page_num) { if (!NetworkConnectionStatus.isNetworkAvailable(getActivity())) { Toast.makeText(getActivity(), "Check your connection and try again", Toast.LENGTH_LONG).show(); } else {//from w ww. j av a 2 s. c o m mAsyncTask = new AsyncTask<String, String, String>() { @Override protected void onPreExecute() { } @Override protected String doInBackground(String... arg0) { JSONObject food = mFatSecretSearch.searchFood(item, page_num); JSONArray FOODS_ARRAY; try { if (food != null) { FOODS_ARRAY = food.getJSONArray("food"); if (FOODS_ARRAY != null) { for (int i = 0; i < FOODS_ARRAY.length(); i++) { JSONObject food_items = FOODS_ARRAY.optJSONObject(i); String food_name = food_items.getString("food_name"); String food_description = food_items.getString("food_description"); String[] row = food_description.split("-"); String id = food_items.getString("food_type"); if (id.equals("Brand")) { brand = food_items.getString("brand_name"); } if (id.equals("Generic")) { brand = "Generic"; } String food_id = food_items.getString("food_id"); mItem.add(new SearchItemResult(food_name, row[1].substring(1), "" + brand, food_id)); } } } } catch (JSONException exception) { exception.printStackTrace(); return "Error"; } return ""; } @Override protected void onPostExecute(String result) { super.onPostExecute(result); searchAdapter.notifyDataSetChanged(); if (listContainer.getCount() > 0) { searchBack.setVisibility(View.VISIBLE); TranslateAnimation slide = new TranslateAnimation(0, 0, listContainer.getHeight(), 0); slide.setStartTime(1000); listContainer.setVisibility(View.VISIBLE); slide.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); slide.setDuration(400); listContainer.startAnimation(slide); } else { searchBack.setVisibility(View.GONE); listContainer.setVisibility(View.GONE); } } @Override protected void onCancelled() { } }; mAsyncTask.execute(); } }
From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java
/** * Shows the name error textfield with the appropriate * error message./*from w w w . ja v a 2 s . co m*/ */ private void showNameError() { mNameErrorState = 1; // Disable the positive button of the dialog setFormIsValidated(false); if (mNameErrorTextView.getVisibility() == View.VISIBLE) { return; // No need to animate in the textview, it's already visible } mNameErrorTextView.setVisibility(View.VISIBLE); AnimationSet fadeInSet = new AnimationSet(true); fadeInSet.addAnimation(new AlphaAnimation(0f, 1f)); fadeInSet.addAnimation(new TranslateAnimation(0f, 0f, -mErrorAnimTranslateY, 0f)); fadeInSet.setDuration(300); mNameErrorTextView.startAnimation(fadeInSet); }
From source file:com.linkbubble.ui.BubbleFlowView.java
public boolean expand(long time, final AnimationEventListener animationEventListener) { CrashTracking.log("BubbleFlowView.expand(" + time + "), mIsExpanded:" + mIsExpanded); if (mIsExpanded) { return false; }//from w w w . j av a2s . co m mDoingCollapse = false; mStillTouchFrameCount = -1; if (DEBUG) { //Log.d(TAG, "[longpress] expand(): mStillTouchFrameCount=" + mStillTouchFrameCount); } int size = mViews.size(); int centerIndex = getCenterIndex(); if (centerIndex == -1) { // fixes #343 return false; } View centerView = mViews.get(centerIndex); boolean addedAnimationListener = false; for (int i = 0; i < size; i++) { View view = mViews.get(i); if (centerView != view) { int xOffset = (int) (centerView.getX() - ((i * mItemWidth) + mEdgeMargin)); TranslateAnimation anim = new TranslateAnimation(xOffset, 0, 0, 0); anim.setDuration(time); anim.setFillAfter(true); if (addedAnimationListener == false) { anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (animationEventListener != null) { animationEventListener.onAnimationEnd(BubbleFlowView.this); } } @Override public void onAnimationRepeat(Animation animation) { } }); addedAnimationListener = true; } view.startAnimation(anim); } } if (centerIndex == 0 && mViews.size() == 1) { if (animationEventListener != null) { animationEventListener.onAnimationEnd(this); } } bringTabViewToFront(centerView); mIsExpanded = true; return true; }