小编jin*_*zju的帖子

Android:子视图从Jelly Bean中的父视图共享压缩状态

代码注释:1.RelativeLayout Clickable attr设置为true,其中有一个子视图,其Clickable attr设置为false.2.没有任何duplicateParentState attr,换句话说,duplicateParentState为false.3.子视图是TextView,其textColor是颜色选择器,因此它可以检查按下的状态.

行为:在level16之前,当单击RelativeLayout时,按下的状态不会传输到他的chlid视图.但是在16级或更高级别,它可以.

原因:setPressed ------> dispatchSetPressed ------>将压缩状态传递给子视图-----> childView.setPressed

15级的View.java onTouchEvent,

case MotionEvent.ACTION_DOWN:
                mHasPerformedLongPress = false;

                if (performButtonActionOnTouchDown(event)) {
                    break;
                }

                // Walk up the hierarchy to determine if we're inside a scrolling container.
                boolean isInScrollingContainer = isInScrollingContainer();

                // For views inside a scrolling container, delay the pressed feedback for
                // a short period in case this is a scroll.
                if (isInScrollingContainer) {
                    mPrivateFlags |= PREPRESSED;
                    if (mPendingCheckForTap == null) {
                        mPendingCheckForTap = new CheckForTap();
                    }
                    postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout()); …
Run Code Online (Sandbox Code Playgroud)

android view touch-event

5
推荐指数
0
解决办法
1641
查看次数

标签 统计

android ×1

touch-event ×1

view ×1