List of usage examples for android.view.animation AlphaAnimation AlphaAnimation
public AlphaAnimation(float fromAlpha, float toAlpha)
From source file:com.fastbootmobile.encore.app.fragments.AlbumViewFragment.java
private void setupHeader(LayoutInflater inflater) { // Load the header View headerView = inflater.inflate(R.layout.header_listview_songs, mListView, false); mIvHero = (ImageView) headerView.findViewById(R.id.ivHero); mTvAlbumName = (TextView) headerView.findViewById(R.id.tvAlbumName); mTvAlbumName.setBackgroundColor(0xBBFFFFFF & mBackgroundColor); if (mAlbum != null) { mTvAlbumName.setText(mAlbum.getName()); }//w ww .j av a2s . c o m if (!Utils.hasLollipop()) { // Since we don't have the transition animation, make sure everything is visible mTvAlbumName.setVisibility(View.VISIBLE); mTvAlbumName.setAlpha(0.0f); mTvAlbumName.animate().alpha(1.0f).setDuration(AlbumActivity.BACK_DELAY).start(); } // Hide download button by default headerView.findViewById(R.id.cpbOffline).setVisibility(View.GONE); mPlayFab = (FloatingActionButton) headerView.findViewById(R.id.fabPlay); // Set source logo ImageView ivSource = (ImageView) headerView.findViewById(R.id.ivSourceLogo); if (mAlbum != null) { mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mAlbum); ivSource.setImageDrawable(mLogoBitmap); } // Set the FAB animated drawable mFabDrawable = new PlayPauseDrawable(getResources(), 1); mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY); mFabDrawable.setYOffset(6); mPlayFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) { if (mFabShouldResume) { PlaybackProxy.play(); mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); mBarDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); } else { PlaybackProxy.playAlbum(mAlbum); } if (Utils.hasLollipop()) { // No Lollipop, no cool animation! showMaterialReelBar(mPlayFab); } } else { mFabShouldResume = true; PlaybackProxy.pause(); mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY); mBarDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY); hideMaterialReelBar(mPlayFab); } } }); mHandler.post(new Runnable() { @Override public void run() { showFab(false, false); } }); mPlayFab.setImageDrawable(mFabDrawable); if (mHeroImage != null) { mIvHero.setImageBitmap(mHeroImage); } else { mIvHero.setImageResource(R.drawable.album_placeholder); } // Set the header view and adapter mListView.addParallaxedHeaderView(headerView); mListView.setAdapter(mAdapter); AlphaAnimation anim = new AlphaAnimation(0.f, 1.f); anim.setDuration(200); mListView.setLayoutAnimation(new LayoutAnimationController(anim)); setupMaterialReelBar(headerView, mReelFabClickListener); }
From source file:com.wdullaer.materialdatetimepicker.date.DatePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int listPosition = -1; int listPositionOffset = 0; int currentView = mDefaultView; if (savedInstanceState != null) { mWeekStart = savedInstanceState.getInt(KEY_WEEK_START); mMinYear = savedInstanceState.getInt(KEY_YEAR_START); mMaxYear = savedInstanceState.getInt(KEY_YEAR_END); currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW); listPosition = savedInstanceState.getInt(KEY_LIST_POSITION); listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET); mMinDate = (Calendar) savedInstanceState.getSerializable(KEY_MIN_DATE); mMaxDate = (Calendar) savedInstanceState.getSerializable(KEY_MAX_DATE); highlightedDays = (HashSet<Calendar>) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS); selectableDays = (TreeSet<Calendar>) savedInstanceState.getSerializable(KEY_SELECTABLE_DAYS); disabledDays = (HashSet<Calendar>) savedInstanceState.getSerializable(KEY_DISABLED_DAYS); mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK); mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED); mAccentColor = savedInstanceState.getInt(KEY_ACCENT); mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE); mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS); mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS); mTitle = savedInstanceState.getString(KEY_TITLE); mOkResid = savedInstanceState.getInt(KEY_OK_RESID); mOkString = savedInstanceState.getString(KEY_OK_STRING); mOkColor = savedInstanceState.getInt(KEY_OK_COLOR); mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID); mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR); mVersion = (Version) savedInstanceState.getSerializable(KEY_VERSION); mTimezone = (TimeZone) savedInstanceState.getSerializable(KEY_TIMEZONE); }// ww w . j a v a 2 s .c o m int viewRes = mVersion == Version.VERSION_1 ? R.layout.mdtp_date_picker_dialog : R.layout.mdtp_date_picker_dialog_v2; View view = inflater.inflate(viewRes, container, false); // All options have been set at this point: round the initial selection if necessary setToNearestDate(mCalendar); mDatePickerHeaderView = (TextView) view.findViewById(R.id.mdtp_date_picker_header); mMonthAndDayView = (LinearLayout) view.findViewById(R.id.mdtp_date_picker_month_and_day); mMonthAndDayView.setOnClickListener(this); mSelectedMonthTextView = (TextView) view.findViewById(R.id.mdtp_date_picker_month); mSelectedDayTextView = (TextView) view.findViewById(R.id.mdtp_date_picker_day); mYearView = (TextView) view.findViewById(R.id.mdtp_date_picker_year); mYearView.setOnClickListener(this); final Activity activity = getActivity(); mDayPickerView = new SimpleDayPickerView(activity, this); mYearPickerView = new YearPickerView(activity, this); // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Utils.isDarkTheme(activity, mThemeDark); } Resources res = getResources(); mDayPickerDescription = res.getString(R.string.mdtp_day_picker_description); mSelectDay = res.getString(R.string.mdtp_select_day); mYearPickerDescription = res.getString(R.string.mdtp_year_picker_description); mSelectYear = res.getString(R.string.mdtp_select_year); int bgColorResource = mThemeDark ? R.color.mdtp_date_picker_view_animator_dark_theme : R.color.mdtp_date_picker_view_animator; view.setBackgroundColor(ContextCompat.getColor(activity, bgColorResource)); mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.mdtp_animator); mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mCalendar.getTimeInMillis()); // TODO: Replace with animation decided upon by the design team. Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); // TODO: Replace with animation decided upon by the design team. Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); Button okButton = (Button) view.findViewById(R.id.mdtp_ok); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); notifyOnDateListener(); dismiss(); } }); okButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mOkString != null) okButton.setText(mOkString); else okButton.setText(mOkResid); Button cancelButton = (Button) view.findViewById(R.id.mdtp_cancel); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); cancelButton.setTypeface(TypefaceHelper.get(activity, "Roboto-Medium")); if (mCancelString != null) cancelButton.setText(mCancelString); else cancelButton.setText(mCancelResid); cancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getActivity()); } if (mDatePickerHeaderView != null) mDatePickerHeaderView.setBackgroundColor(Utils.darkenColor(mAccentColor)); view.findViewById(R.id.mdtp_day_picker_selected_date_layout).setBackgroundColor(mAccentColor); // Buttons can have a different color if (mOkColor != -1) okButton.setTextColor(mOkColor); else okButton.setTextColor(mAccentColor); if (mCancelColor != -1) cancelButton.setTextColor(mCancelColor); else cancelButton.setTextColor(mAccentColor); if (getDialog() == null) { view.findViewById(R.id.mdtp_done_background).setVisibility(View.GONE); } updateDisplay(false); setCurrentView(currentView); if (listPosition != -1) { if (currentView == MONTH_AND_DAY_VIEW) { mDayPickerView.postSetSelection(listPosition); } else if (currentView == YEAR_VIEW) { mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset); } } mHapticFeedbackController = new HapticFeedbackController(activity); return view; }
From source file:com.fastbootmobile.encore.app.fragments.PlaylistViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_playlist_view, container, false); assert root != null; if (mPlaylist == null) { // If playlist couldn't load, abort early return root; }//from w w w . j av a2s.c om mListViewContents = (PlaylistListView) root.findViewById(R.id.lvPlaylistContents); // Setup the parallaxed header View headerView = inflater.inflate(R.layout.header_listview_songs, mListViewContents, false); mListViewContents.addParallaxedHeaderView(headerView); mAdapter = new PlaylistAdapter(); mListViewContents.setAdapter(mAdapter); mListViewContents.setOnScrollListener(new ScrollStatusBarColorListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (view.getChildCount() == 0 || getActivity() == null) { return; } final float heroHeight = mIvHero.getMeasuredHeight(); final float scrollY = getScroll(view); final float toolbarBgAlpha = Math.min(1, scrollY / heroHeight); final int toolbarAlphaInteger = (((int) (toolbarBgAlpha * 255)) << 24) | 0xFFFFFF; mColorDrawable.setColor(toolbarAlphaInteger & getResources().getColor(R.color.primary)); SpannableString spannableTitle = new SpannableString( mPlaylist.getName() != null ? mPlaylist.getName() : ""); mAlphaSpan.setAlpha(toolbarBgAlpha); ActionBar actionbar = ((AppActivity) getActivity()).getSupportActionBar(); if (actionbar != null) { actionbar.setBackgroundDrawable(mColorDrawable); spannableTitle.setSpan(mAlphaSpan, 0, spannableTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); actionbar.setTitle(spannableTitle); if (Utils.hasLollipop()) { getActivity().getWindow().setStatusBarColor( toolbarAlphaInteger & getResources().getColor(R.color.primary_dark)); } } } }); headerView.findViewById(R.id.pbAlbumLoading).setVisibility(View.GONE); mIvHero = (ImageView) headerView.findViewById(R.id.ivHero); mTvPlaylistName = (TextView) headerView.findViewById(R.id.tvAlbumName); // Download button mOfflineBtn = (CircularProgressButton) headerView.findViewById(R.id.cpbOffline); mOfflineBtn.setAlpha(0.0f); mOfflineBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ProviderIdentifier pi = mPlaylist.getProvider(); IMusicProvider provider = PluginsLookup.getDefault().getProvider(pi).getBinder(); try { if (mPlaylist.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_NO) { provider.setPlaylistOfflineMode(mPlaylist.getRef(), true); mOfflineBtn.setIndeterminateProgressMode(true); mOfflineBtn.setProgress(1); if (ProviderAggregator.getDefault().isOfflineMode()) { Toast.makeText(getActivity(), R.string.toast_offline_playlist_sync, Toast.LENGTH_SHORT) .show(); } } else { provider.setPlaylistOfflineMode(mPlaylist.getRef(), false); mOfflineBtn.setProgress(0); } } catch (RemoteException e) { Log.e(TAG, "Cannot set this playlist to offline mode", e); mOfflineBtn.setProgress(-1); } } }); mHandler.sendEmptyMessageDelayed(UPDATE_OFFLINE_STATUS, 300); mTvPlaylistName.setText(mPlaylist.getName()); Bitmap hero = Utils.dequeueBitmap(PlaylistActivity.BITMAP_PLAYLIST_HERO); if (hero == null) { mIvHero.setImageResource(R.drawable.album_placeholder); } else { mIvHero.setImageBitmap(hero); // Request the higher resolution loadArt(); } mPlayFab = (FloatingActionButton) headerView.findViewById(R.id.fabPlay); // Set source logo mIvSource = (ImageView) headerView.findViewById(R.id.ivSourceLogo); mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mPlaylist); mIvSource.setImageDrawable(mLogoBitmap); // Set the FAB animated drawable mFabDrawable = new PlayPauseDrawable(getResources(), 1); mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY); mFabDrawable.setYOffset(6); mPlayFab.setImageDrawable(mFabDrawable); mPlayFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) { if (mFabShouldResume) { PlaybackProxy.play(); mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); mFabDrawable.setBuffering(true); } else { playNow(); } if (Utils.hasLollipop()) { showMaterialReelBar(mPlayFab); } } else { mFabShouldResume = true; PlaybackProxy.pause(); mFabDrawable.setBuffering(true); } } }); // Fill the playlist mAdapter.setPlaylist(mPlaylist); // Set the list listener mListViewContents.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Song song = mAdapter.getItem(i - 1); if (Utils.canPlaySong(song)) { PlaybackProxy.clearQueue(); PlaybackProxy.queuePlaylist(mPlaylist, false); PlaybackProxy.playAtIndex(i - 1); // Update FAB mFabShouldResume = true; mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); mFabDrawable.setBuffering(true); if (Utils.hasLollipop()) { showMaterialReelBar(mPlayFab); } } } }); // Set the display animation AlphaAnimation anim = new AlphaAnimation(0.f, 1.f); anim.setDuration(200); mListViewContents.setLayoutAnimation(new LayoutAnimationController(anim)); setupMaterialReelBar(root, mReelFabClickListener); // Setup the opening animations for non-Lollipop devices if (!Utils.hasLollipop()) { mTvPlaylistName.setVisibility(View.VISIBLE); mTvPlaylistName.setAlpha(0.0f); mTvPlaylistName.animate().alpha(1.0f).setDuration(AlbumActivity.BACK_DELAY).start(); } mIvSource.setAlpha(0.0f); mIvSource.animate().alpha(1).setDuration(200).start(); return root; }
From source file:com.sahildave.snackbar.SnackBar.java
private AnimationSet getExitAnimation() { //Out/*from w ww. ja va 2 s. co m*/ mOutAnimationSet = new AnimationSet(false); TranslateAnimation mSlideOutAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f); mSlideOutAnimation.setFillAfter(true); AlphaAnimation mFadeOutAnimation = new AlphaAnimation(1.0f, 0.0f); mFadeOutAnimation.setFillAfter(true); mOutAnimationSet.addAnimation(mSlideOutAnimation); mOutAnimationSet.addAnimation(mFadeOutAnimation); mOutAnimationSet.setDuration(OUT_ANIMATION_DURATION); return mOutAnimationSet; }
From source file:com.money.manager.ex.fragment.HomeFragment.java
public LayoutAnimationController setAnimationView(View view) { AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(250);//from w w w . ja v a 2 s . c o m set.addAnimation(animation); animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(150); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f); return controller; }
From source file:com.umeng.comm.ui.fragments.BaseFeedsFragment.java
/** * //from www . j a va2 s.c om */ private void hidePostButtonWithAnim() { AlphaAnimation animation = new AlphaAnimation(1.0f, 0f); animation.setDuration(500); mPostBtn.setVisibility(View.GONE); mPostBtn.startAnimation(animation); }
From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvShareFragment.java
/** * Load QR Code asynchronously and with a fade in animation *//* www . j a va2 s. c o m*/ private void setFingerprint(byte[] fingerprintBlob) { mFingerprint = fingerprintBlob; final String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fingerprintBlob); mFingerprintView.setText(KeyFormattingUtils.colorizeFingerprint(fingerprint)); if (mQrCodeBitmapCache != null) { return; } AsyncTask<Void, Void, Bitmap> loadTask = new AsyncTask<Void, Void, Bitmap>() { protected Bitmap doInBackground(Void... unused) { Uri uri = new Uri.Builder().scheme(Constants.FINGERPRINT_SCHEME).opaquePart(fingerprint).build(); // render with minimal size return QrCodeUtils.getQRCodeBitmap(uri, 0); } protected void onPostExecute(Bitmap qrCode) { // cache for later, and if we are attached request re-layout mQrCodeBitmapCache = qrCode; if (ViewKeyAdvShareFragment.this.isAdded()) { mQrCode.requestLayout(); // simple fade-in animation AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(200); mQrCode.startAnimation(anim); } } }; loadTask.execute(); }
From source file:fiskinfoo.no.sintef.fiskinfoo.CardViewFragment.java
public Animation getBlinkAnimation() { Animation animation = new AlphaAnimation(1, 0); animation.setDuration(600);// w w w . ja v a2 s .c o m animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(1); animation.setRepeatMode(Animation.REVERSE); return animation; }
From source file:com.sonvp.tooltip.Tooltip.java
@Override public boolean onPreDraw() { container.getViewTreeObserver().removeOnPreDrawListener(this); Context context = container.getContext(); if (!(context instanceof Activity)) { return false; }/*from w w w . j a v a 2 s . com*/ DisplayMetrics displayMetrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int displayWidth = displayMetrics.widthPixels; int displayHeight = displayMetrics.heightPixels; int displayTop = getStatusBarHeight(); int anchorTop = rectAnchorView.top; int anchorLeft = rectAnchorView.left; int anchorWidth = anchorView.getWidth(); int anchorHeight = anchorView.getHeight(); int textWidth = viewTooltip.getWidth(); //default height 1 line int textHeight = viewTooltip.getHeight(); int arrowWidth = arrow.getWidth(); int arrowHeight = arrow.getHeight(); int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(displayWidth, View.MeasureSpec.AT_MOST); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); if (gravity == Gravity.TOP || gravity == Gravity.BOTTOM) { int width = Math.max(textWidth, arrowWidth); int height = textHeight + arrowHeight; int leftPadding; int topPadding; if (gravity == Gravity.TOP) { topPadding = anchorTop - height; } else { // gravity == Gravity.BOTTOM topPadding = anchorTop + anchorHeight; } int anchorHorizontalCenter = anchorLeft + anchorWidth / 2; int left = anchorHorizontalCenter - width / 2; int right = left + width; leftPadding = Math.max(0, right > displayWidth ? displayWidth - width : left); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams(); layoutParams.leftMargin = anchorHorizontalCenter - leftPadding - arrowWidth / 2; arrow.setLayoutParams(layoutParams); popupWindow.update(leftPadding, topPadding, container.getWidth(), container.getHeight()); pivotX = width / 2; pivotY = gravity == Gravity.TOP ? height : 0; } else { // gravity == Gravity.LEFT || gravity == Gravity.RIGHT int width = textWidth + arrowWidth; int leftPadding; int topPadding; int rightPadding = 0; if (gravity == Gravity.LEFT) { leftPadding = Math.max(0, anchorLeft - width); leftPadding += (int) builder.toolTipMargin; rightPadding = displayWidth - anchorLeft; } else { // gravity == Gravity.RIGHT leftPadding = anchorLeft + anchorWidth; rightPadding = (int) builder.toolTipMargin; } if (viewTooltip instanceof TextView) { TextView text = (TextView) viewTooltip; text.setMaxWidth(displayWidth - rightPadding - leftPadding - arrowWidth); viewTooltip.measure(widthMeasureSpec, heightMeasureSpec); textHeight = viewTooltip.getMeasuredHeight(); // height multi line } int height = Math.max(textHeight, arrowHeight); int anchorVerticalCenter = anchorTop + anchorHeight / 2; int top = anchorVerticalCenter - height / 2; int bottom = top + height; if (builder.arrowGravity == Gravity.TOP) { top = anchorTop; bottom = anchorTop + height; } else if (builder.arrowGravity == Gravity.BOTTOM) { top = anchorTop + anchorHeight - height; } topPadding = Math.max(0, bottom > displayHeight ? displayHeight - height - (int) builder.toolTipMargin : top); topPadding = Math.max(0, topPadding < displayTop ? displayTop + (int) builder.toolTipMargin : topPadding); container.measure(widthMeasureSpec, heightMeasureSpec); int popupWidth = container.getMeasuredWidth(); int popupHeight = container.getMeasuredHeight(); popupWindow.update(leftPadding, topPadding, popupWidth, popupHeight); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams(); layoutParams.topMargin = anchorVerticalCenter - topPadding - arrowHeight / 2; arrow.setLayoutParams(layoutParams); pivotX = gravity == Gravity.LEFT ? popupWidth : 0; pivotY = anchorVerticalCenter - topPadding; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { container.setAlpha(0.0F); container.setPivotX(pivotX); container.setPivotY(pivotY); container.setScaleX(0.0F); container.setScaleY(0.0F); container.animate().setDuration(ANIMATION_DURATION).scaleX(1.0F).scaleY(1.0F).alpha(1.0F); } else { AnimationSet animationSet = new AnimationSet(true); animationSet.setDuration(ANIMATION_DURATION); animationSet.addAnimation(new AlphaAnimation(0.0F, 1.0F)); animationSet.addAnimation(new ScaleAnimation(0.0F, 1.0F, 0.0F, 1.0F, pivotX, pivotY)); container.startAnimation(animationSet); } return false; }
From source file:com.devbrackets.android.exomedia.DefaultControls.java
/** * Performs the control visibility animation for showing or hiding * this view//from w w w . j av a 2 s. c om * * @param toVisible True if the view should be visible at the end of the animation */ private void animateVisibility(boolean toVisible) { if (isVisible == toVisible) { return; } float startAlpha = toVisible ? 0 : 1; float endAlpha = toVisible ? 1 : 0; AlphaAnimation animation = new AlphaAnimation(startAlpha, endAlpha); animation.setDuration(CONTROL_VISIBILITY_ANIMATION_LENGTH); animation.setFillAfter(true); startAnimation(animation); isVisible = toVisible; onVisibilityChanged(); }