我在我的android应用程序中使用了showCaseView legacy(它有手的动画)。但是,这个手势似乎并不是相对于视图开始的。相反,它对屏幕来说似乎是绝对的。这是我使用的以下代码:
final ShowcaseView sv;
ShowcaseView.ConfigOptions co = new ShowcaseView.ConfigOptions();
co.hideOnClickOutside = false;
co.block=true;
sv = ShowcaseView.insertShowcaseView(R.id.pen, this," R.string.showcase_title"," R.string.showcase_message", co);
View v=(View)findViewById(R.id.pen);
sv.animateGesture(0, 0, 0, -500, false);这是我的模拟器的顶部,动画从这里开始:

这将在屏幕的左上角显示一只手。(我的猜测是视图的位置返回0。
问题出在哪里?
发布于 2014-08-06 04:28:41
你最好的选择可能是使用DisplayMetrics来放置手,这就是我所做的,它似乎工作得很好。
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int width = displaymetrics.widthPixels;
float offsetEndY = height / 2 + 50;
float offsetEndX = -width;
float offsetStartY = height / 2 + 50;
float offsetStartX = -width / 2;
if (sv == null) {
sv = ShowcaseView.insertShowcaseView(width, 0, activity, "Menu", "Swipe to access more options", mOptions)
.setTextColors(Color.BLUE, Color.BLACK);
sv.animateGesture(offsetStartX, offsetStartY, offsetEndX, offsetEndY);发布于 2015-03-06 06:17:45
我也有同样的问题,我在不同的阶段记录了showcase的位置,我发现在调用show()之后的一段(非常短的)时间内,正确的位置会被奇怪地计算出来。当我打电话的时候
showcaseView.show();
showcaseView.animateGesture(0, 0, 0, -400);这不管用。
简单的解决方案是显示一些延迟的手势(在我的情况下200ms就足够了-在许多设备上进行了测试):
showcaseView.show();
showcaseView.postDelayed(new Runnable() {
@Override
public void run() {
showcaseView.animateGesture(0, 0, 0, -400);
}
}, 200);https://stackoverflow.com/questions/25145974
复制相似问题