List of usage examples for android.view.animation TranslateAnimation setFillEnabled
public void setFillEnabled(boolean fillEnabled)
From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java
/** * Method to display the menu of the app. *///from w w w. j a v a 2s. com private void displaySideMenu() { TranslateAnimation animation = null; // If it's a tablet in landscape, the menu is always displayed, else // it's activated by the user if (!isTablet || (isTablet && screenOrientation == Orientation.PORTRAIT)) { if (!showingMenu) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mainRL.getLayoutParams(); animation = new TranslateAnimation(0, listRL.getMeasuredWidth() - layoutParams.leftMargin, 0, 0); animation.setDuration(animationDuration); animation.setFillEnabled(true); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // At the end, set the final position as the current one RelativeLayout.LayoutParams lpList = (LayoutParams) mainRL.getLayoutParams(); lpList.setMargins(listRL.getMeasuredWidth(), 0, -listRL.getMeasuredWidth(), 0); mainRL.setLayoutParams(lpList); showingMenu = true; } }); } else { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mainRL.getLayoutParams(); animation = new TranslateAnimation(0, -layoutParams.leftMargin, 0, 0); animation.setDuration(animationDuration); animation.setFillEnabled(true); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // At the end, set the final position as the current one RelativeLayout.LayoutParams mainContenrLP = (LayoutParams) mainRL.getLayoutParams(); mainContenrLP.setMargins(0, 0, 0, 0); mainRL.setLayoutParams(mainContenrLP); showingMenu = false; } }); } mainRL.startAnimation(animation); } else { // Showing the menu since the tablet is in landscape orientation RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mainRL.getLayoutParams(); animation = new TranslateAnimation(0, listRL.getMeasuredWidth() - layoutParams.leftMargin, 0, 0); animation.setDuration(animationDuration); animation.setFillEnabled(true); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // At the end, set the final position as the current one RelativeLayout.LayoutParams lpList = (LayoutParams) mainRL.getLayoutParams(); lpList.setMargins(listRL.getMeasuredWidth(), 0, -listRL.getMeasuredWidth(), 0); mainRL.setLayoutParams(lpList); showingMenu = true; } }); mainRL.startAnimation(animation); } }
From source file:com.zoffcc.applications.zanavi.Navit.java
static void animate_bottom_bar_down() { final FrameLayout a = (FrameLayout) Global_Navit_Object.findViewById(R.id.bottom_bar_slide); // System.out.println("FRAG:animate_bottom_bar_down:014"); // set bottom end positon correctly?? bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; final int move_by = (int) (bottom_y_margin_bottom_bar_touch - cur_y_margin_bottom_bar_touch); TranslateAnimation animation = new TranslateAnimation(0, 0, 0, move_by); // new TranslateAnimation(xFrom,xTo, yFrom,yTo) animation.setDuration(bottom_bar_snap_duration); // animation duration animation.setFillAfter(true);//w ww . j av a 2 s. c o m animation.setFillEnabled(true); animation.setRepeatCount(0); // animation repeat count animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // set bottom end positon correctly?? bottom_y_margin_bottom_bar_touch = Navit.map_view_height + Navit.actionBarHeight + bottom_bar_px - Navit.bottom_bar_slider_shadow_px; cur_y_margin_bottom_bar_touch = bottom_y_margin_bottom_bar_touch; RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams(); relativeParams.setMargins(0, (int) bottom_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom a.setLayoutParams(relativeParams); a.requestLayout(); TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0); anim.setFillAfter(true); anim.setFillEnabled(true); anim.setDuration(1); a.startAnimation(anim); // remove roadbook fragment ----------- try { if (road_book != null) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); // System.out.println("FRAG:dettach:002"); fragmentTransaction.detach(road_book); fragmentTransaction.remove(road_book).commit(); road_book = null; } } catch (Exception ef) { } // remove roadbook fragment ----------- } }); a.startAnimation(animation); }
From source file:com.zoffcc.applications.zanavi.Navit.java
void animate_bottom_bar_up() { final FrameLayout a = (FrameLayout) findViewById(R.id.bottom_bar_slide); TranslateAnimation animation = new TranslateAnimation(0, 0, 0, -cur_y_margin_bottom_bar_touch); animation.setDuration(bottom_bar_snap_duration); // animation duration animation.setFillAfter(true);// w w w.j av a2 s . c o m animation.setFillEnabled(true); animation.setRepeatCount(0); // animation repeat count animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { cur_y_margin_bottom_bar_touch = 0; RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) a.getLayoutParams(); relativeParams.setMargins(0, (int) cur_y_margin_bottom_bar_touch, 0, 0); // left, top, right, bottom a.setLayoutParams(relativeParams); a.requestLayout(); TranslateAnimation anim = new TranslateAnimation(0, 0, 0, 0); anim.setFillAfter(true); anim.setFillEnabled(true); anim.setDuration(1); a.startAnimation(anim); } }); a.startAnimation(animation); }