【发布时间】:2017-01-18 15:32:53
【问题描述】:
我没有使用锚,它应该可以工作。 最初,可见性消失了(由 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>
减少主要活动:
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 上的位置工作...我将代码简化为更具可读性,希望这不是问题。
【问题讨论】:
标签: java android xml android-layout floating-action-button