gpt4 book ai didi

android - 调用 FloatingActionButton.hide() 是否与将 FloatingActionButton 的可见性设置为 Gone 相同?

转载 作者:行者123 更新时间:2023-11-30 01:14:00 25 4
gpt4 key购买 nike

只是想澄清一个概念上的疑问。 float 操作按钮的 hide() 函数类似于 visibility.GONE 还是 visibility.INVISIBLE?

最佳答案

简而言之:是的。

以下是从设计支持库中为 ICS (Android SKD 15) 实现的此功能:

@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();
}
}
}
});
}
}

基本上它只是通过动画改变可见性。

关于android - 调用 FloatingActionButton.hide() 是否与将 FloatingActionButton 的可见性设置为 Gone 相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38140240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com