简介
aosp10的手势导航默认是关闭的,在源码目录下的 /frameworks/base/core/res/res/values/config.xml文件中,把
R.bool.config_swipe_up_gesture_setting_available变量由fase改为true,然后进行编译
优化侧滑返回效果
我把Android 10手势导航的侧滑返回效果优化了一波 - 掘金 (juejin.cn)
实现拖拽时凸起效果
NavigationBarEdgePanel中,在onDraw()中只需将demo中的代码稍微修改一下即可:
@Override
protected void onDraw(Canvas canvas) {
// 箭头所在位置
float pointerPosition = mCurrentTranslation - mArrowThickness / 2.0f;
...
// draw wave
mPath.reset();
int factor = mIsLeftPanel ? 1 : -1;
int currentY = getHeight() / 2;
// 凸起上部Y
int topY = 0;
// 凸起下部Y
int bottomY = getHeight();
// 凸起底部X
int footX = mIsLeftPanel ? 0 : getWidth();
// 凸起顶部X
int peekX = (int) (footX + factor * (mIsLeftPanel ? pointerPosition : pointerPosition - getStaticArrowWidth()) / 2);
p1.x = footX;
p1.y = topY + 75;
p2.x = peekX;
p2.y = topY + 100;
p4.x = peekX;
p4.y = bottomY - 100;
p5.x = footX;
p5.y = bottomY - 75;
mPath.moveTo(footX, topY);
mPath.cubicTo(p1.x, p1.y, p2.x, p2.y, peekX, currentY);
mPath.cubicTo(p4.x, p4.y, p5.x, p5.y, footX, bottomY);
mPath.close();
canvas.drawPath(mPath, mWavePaint);
}