0
导航抽屉抽屉式导航自定义触控动作有3种行为android系统中创建的Android
- Always opened, and can be close only programming using LOCK_MODE_LOCKED_OPEN.
- Always closed, and can be open only programming LOCK_MODE_LOCKED_CLOSED.
- User can open and close the drawer. using LOCK_MODE_UNLOCKED
第三个,如果用户点击了侧的抽屉打开时会自动关闭。而第一个将永远保持开放。
I need to have custom one that user can open and close the drawer, and when he clicks outside the drawer it will remains open.
我想重写onInterceptTouchEvent。
任何一个人做了一些similer?
/*********交锋*********** 我延长了DrawerLayout,和它的作品还没有确定,如果100%
public class CustomDrawerLayout extends DrawerLayout {
Context ccontext;
public CustomDrawerLayout(Context context) {
this(context, null);
}
public CustomDrawerLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CustomDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
super(context,attrs,defStyle);
this.ccontext = context;
}
//@Override
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
switch (action & MotionEventCompat.ACTION_MASK) {
case MotionEvent.ACTION_UP: {
final float x = ev.getX();
final float y = ev.getY();
boolean peekingOnly = true;
final View touchedView = findTopChildUnder((int) x, (int) y);
if (touchedView != null && touchedView instanceof FrameLayout) {
return true;
}
break;
}
}
return super.onTouchEvent(ev);
}
public View findTopChildUnder(int x, int y) {
final int childCount = this.getChildCount();
for (int i = childCount - 1; i >= 0; i--) {
final View child = this.getChildAt(i);
if (x >= child.getLeft() && x < child.getRight() &&
y >= child.getTop() && y < child.getBottom()) {
return child;
}
}
return null;
}
}
我知道,但这是我的应用程序需要 –
AFAIK这并不支持它 – VVB
,但它现在适用于我 –