1
只是想澄清一個概念上的疑問。懸浮動作按鈕的hide()函數類似於visibility.GONE或visibility.INVISIBLE?調用FloatingActionButton.hide()與將FloatingActionButton的可見性設置爲「消失」一樣嗎?
只是想澄清一個概念上的疑問。懸浮動作按鈕的hide()函數類似於visibility.GONE或visibility.INVISIBLE?調用FloatingActionButton.hide()與將FloatingActionButton的可見性設置爲「消失」一樣嗎?
總之:是的。
下面是這個函數的從設計支持庫中提取的ICS(Android的SKD 15)的implemntation:
@Override
void hide(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) {
if (mIsHiding || mView.getVisibility() != View.VISIBLE) {
// A hide animation is in progress, or we're already hidden. Skip the call
if (listener != null) {
listener.onHidden();
}
return;
}
if (!ViewCompat.isLaidOut(mView) || mView.isInEditMode()) {
// If the view isn't laid out, or we're in the editor, don't run the animation
mView.internalSetVisibility(View.GONE, fromUser);
if (listener != null) {
listener.onHidden();
}
} else {
mView.animate().cancel();
mView.animate()
.scaleX(0f)
.scaleY(0f)
.alpha(0f)
.setDuration(SHOW_HIDE_ANIM_DURATION)
.setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR)
.setListener(new AnimatorListenerAdapter() {
private boolean mCancelled;
@Override
public void onAnimationStart(Animator animation) {
mIsHiding = true;
mCancelled = false;
mView.internalSetVisibility(View.VISIBLE, fromUser);
}
@Override
public void onAnimationCancel(Animator animation) {
mIsHiding = false;
mCancelled = true;
}
@Override
public void onAnimationEnd(Animator animation) {
mIsHiding = false;
if (!mCancelled) {
mView.internalSetVisibility(View.GONE, fromUser);
if (listener != null) {
listener.onHidden();
}
}
}
});
}
}
動畫基本上它只是改變的知名度。
很棒的回答。謝謝 –