gpt4 book ai didi

java - fab.setVisibility(View.GONE) 不工作

转载 作者:行者123 更新时间:2023-11-29 19:34:21 24 4
gpt4 key购买 nike

我没有使用 anchor ,它应该可以工作。最初,可见性消失了(由 XML 设置)。当我按下一个按钮时,它变得可见(直到这里,工作)。然后,当我按下另一个按钮时,它应该消失了,但没有任何反应。减少 XML:

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
android:id="@+id/tbTela3"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ToolBar"
app:titleTextColor="#757575"
app:subtitleTextColor="#757575" />

<android.support.design.widget.CoordinatorLayout
android:id="@+id/cLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tbTela3">

<ScrollView>
[...]
</ScrollView>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:elevation="8dp"
android:src="@drawable/replay"
android:visibility="gone"/>

</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>

减少主要 Activity :

public void ZoomIn() {

[...]

zoomIn.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation anim) {}
public void onAnimationRepeat(Animation anim) {}

public void onAnimationEnd(Animation anim) {
fab.setVisibility(View.VISIBLE); // WORKS FINE
}
});

fab.startAnimation(zoomIn);
}

[...]

public void Clear() {

[...]

anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
readX.requestFocus();
cardII.setVisibility(View.GONE); // WORKS FINE TOO
fab.setVisibility(View.GONE); // BUT THIS DON'T

fadeOut.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation anim) {}
public void onAnimationRepeat(Animation anim) {}

public void onAnimationEnd(Animation anim) {
clear.setVisibility(View.INVISIBLE);
}
});

clear.startAnimation(fadeOut);
}
});

anim.start();

}

fab.setVisibility(View.GONE) 无法独立于它在 Clear 上的位置工作...我减少了代码以提高可读性,希望这不是问题。

最佳答案

        CoordinatorLayout.LayoutParams p = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
p.setAnchorId(View.NO_ID);
fab.setLayoutParams(p);
fab.setVisibility(View.GONE);

或者试试

    fab.show(); //show
fab.hide(); //hide

关于java - fab.setVisibility(View.GONE) 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39429248/

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