gpt4 book ai didi

android:禁用来自 ViewSwitcher 的非 Activity subview 的点击

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

我有一个带有翻转动画的自定义 ViewSwitcher。问题是当前未显示的 View (包含子按钮)正在拦截来自 Activity View 的点击。我尝试将可见性设置为不可见或消失(没有用),我尝试遍历所有 subview 并设置 setClickable(false) 但这没有用。

也许我在错误的地方应用了我的更改?以下是我的代码的相关部分。

public class ViewFlip3D extends ViewSwitcher {
// switches views
public void flip() {
float centerX = getWidth() / 2.0f;
float centerY = getHeight() / 2.0f;

Flip3D animOut = new Flip3D(-90, 0, centerX, centerY);
animOut.setDuration(500);
animOut.setInterpolator(new AccelerateInterpolator());
animOut.setFillAfter(true);

Flip3D animIn = new Flip3D(0, 90, centerX, centerY);
animIn.setDuration(500);
animIn.setInterpolator(new DecelerateInterpolator());
animIn.setFillAfter(true);

animIn.setAnimationListener(new ShowNextView(this, animOut));

ViewGroup view = (ViewGroup) getCurrentView();

// Disable clicks here!
// like: view.DisableClicksFromAllChildViews();

view.startAnimation(animIn);
}

private final class ShowNextView implements Animation.AnimationListener {
public void onAnimationEnd(Animation animation) {
container.showNext();
ViewGroup view = (ViewGroup) container.getCurrentView();
view.startAnimation(flipin);

// Enable clicks here!
// like: view.EnableClicksFromAllChildViews();
}
}
}

最佳答案

当您希望 View 不受影响时,移除填充或调用 clearAnimation。

如果这些都不适合您的需要,您可以递归循环子项并将可点击设置为 false。

关于android:禁用来自 ViewSwitcher 的非 Activity subview 的点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4697343/

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