当前位置: 首页>>代码示例>>Java>>正文


Java ViewParent类代码示例

本文整理汇总了Java中android.view.ViewParent的典型用法代码示例。如果您正苦于以下问题:Java ViewParent类的具体用法?Java ViewParent怎么用?Java ViewParent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ViewParent类属于android.view包,在下文中一共展示了ViewParent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transformMotionEventToLocal

import android.view.ViewParent; //导入依赖的package包/类
/**
 * Recursive helper method that applies transformations in post-order.
 *
 * @param ev the on-screen motion event
 */
private static void transformMotionEventToLocal(@NonNull View view, @NonNull MotionEvent ev) {
    final ViewParent parent = view.getParent();
    if (parent instanceof View) {
        final View vp = (View) parent;
        transformMotionEventToLocal(vp, ev);
        ev.offsetLocation(vp.getScrollX(), vp.getScrollY());
    } // TODO: Use reflections to access ViewRootImpl
    // else if (parent instanceof ViewRootImpl) {
    //    final ViewRootImpl vr = (ViewRootImpl) parent;
    //    ev.offsetLocation(0, vr.mCurScrollY);
    // }

    ev.offsetLocation(-view.getLeft(), -view.getTop());

    Matrix matrix = view.getMatrix();
    if (matrix != null) {
        ev.transform(matrix);
    }
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:25,代码来源:ViewUtils.java

示例2: requestDisallowInterceptTouchEvent

import android.view.ViewParent; //导入依赖的package包/类
/**
 * 是否请求当前view的父view不要拦截事件
 *
 * @param view
 * @param disallowIntercept true-请求父view不要拦截,false-父view可以拦截
 */
public static void requestDisallowInterceptTouchEvent(View view, boolean disallowIntercept)
{
    ViewParent parent = view.getParent();
    if (parent == null)
    {
        return;
    }
    parent.requestDisallowInterceptTouchEvent(disallowIntercept);
}
 
开发者ID:zj565061763,项目名称:switchbutton,代码行数:16,代码来源:FTouchHelper.java

示例3: instantiateItem

import android.view.ViewParent; //导入依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position)
{

    //对ViewPager页号求模取出View列表中要显示的项
    position %= mList.size();
    if (position < 0)
    {
        position = mList.size() + position;
    }
    ImageView v = mList.get(position);
    pos = position;
    v.setScaleType(ImageView.ScaleType.CENTER);
    //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
    ViewParent vp = v.getParent();
    if (vp != null)
    {
        ViewGroup parent = (ViewGroup) vp;
        parent.removeView(v);
    }
    v.setOnClickListener(v1 -> {

        if (mViewPagerOnItemClickListener != null)
        {
            mViewPagerOnItemClickListener.onItemClick();
        }
    });


    container.addView(v);
    return v;
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:33,代码来源:BannerAdapter.java

示例4: onDrag

import android.view.ViewParent; //导入依赖的package包/类
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    if (DEBUG) {
        LogManager.getLogger().d(LOG_TAG,
                String.format("onDrag: dx: %.2f. dy: %.2f", dx, dy));
    }

    ImageView imageView = getImageView();
    mSuppMatrix.postTranslate(dx, dy);
    checkAndDisplayMatrix();

    /**
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = imageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling() && !mBlockParentIntercept) {
        if (mScrollEdge == EDGE_BOTH
                || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        }
    } else {
        if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:40,代码来源:PhotoViewAttacher.java

示例5: intersectVisibleToUser

import android.view.ViewParent; //导入依赖的package包/类
private boolean intersectVisibleToUser(Rect localRect) {
    if (localRect == null || localRect.isEmpty() || this.mView.getWindowVisibility() != 0) {
        return false;
    }
    ViewParent viewParent = this.mView.getParent();
    while (viewParent instanceof View) {
        View view = (View) viewParent;
        if (ViewCompat.getAlpha(view) <= 0.0f || view.getVisibility() != 0) {
            return false;
        }
        viewParent = view.getParent();
    }
    if (viewParent == null || !this.mView.getLocalVisibleRect(this.mTempVisibleRect)) {
        return false;
    }
    return localRect.intersect(this.mTempVisibleRect);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:ExploreByTouchHelper.java

示例6: requestChildFocus

import android.view.ViewParent; //导入依赖的package包/类
@Override
public void requestChildFocus(View child, View focused) {
    /*
     * Normally a ScrollView will scroll the child into view.
     * Prevent this when a MessageWebView is first touched,
     * assuming it already is at least partially in view.
     * 
     */
    if (mSkipWebViewScroll  &&
            focused instanceof MessageWebView &&
            focused.getGlobalVisibleRect(new Rect())) {
        mSkipWebViewScroll = false;
        super.requestChildFocus(child, child);
        ViewParent parent = getParent();
        if (parent != null) {
            parent.requestChildFocus(this, focused);
        }
    } else {
        super.requestChildFocus(child, focused);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:22,代码来源:NonLockingScrollView.java

示例7: setJSResponder

import android.view.ViewParent; //导入依赖的package包/类
public void setJSResponder(int reactTag, int initialReactTag, boolean blockNativeResponder) {
  if (!blockNativeResponder) {
    mJSResponderHandler.setJSResponder(initialReactTag, null);
    return;
  }

  View view = mTagsToViews.get(reactTag);
  if (initialReactTag != reactTag && view instanceof ViewParent) {
    // In this case, initialReactTag corresponds to a virtual/layout-only View, and we already
    // have a parent of that View in reactTag, so we can use it.
    mJSResponderHandler.setJSResponder(initialReactTag, (ViewParent) view);
    return;
  }

  if (mRootTags.get(reactTag)) {
    SoftAssertions.assertUnreachable(
        "Cannot block native responder on " + reactTag + " that is a root view");
  }
  mJSResponderHandler
      .setJSResponder(initialReactTag, view.getParent());
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:22,代码来源:NativeViewHierarchyManager.java

示例8: getVirtualViewCoordinates

import android.view.ViewParent; //导入依赖的package包/类
/**
 * Get virtual view coordinates of a given {@link View}.
 * <p/>
 * This function always returns the coordinate of the top-left corner of the given view,
 * regardless of left-to-right (LTR) vs. right-to-left (RTL) mode. Note that in RTL mode, this
 * is not the corner that corresponds to the block's workspace coordinates. Use
 * {@link #getWorkspaceCoordinates(View, WorkspacePoint)} to obtain  the workspace coordinates
 * of a block from its view, adjusted for RTL mode if necessary.
 *
 * @param view The view to find the position of.
 * @param viewPosition The Point to store the results in.
 */
public void getVirtualViewCoordinates(View view, ViewPoint viewPosition) {
    int leftRelativeToWorkspace = view.getLeft();
    int topRelativeToWorkspace = view.getTop();

    // Move up the parent hierarchy and add parent-relative view coordinates.
    ViewParent viewParent = view.getParent();
    while (viewParent != null) {
        if (viewParent instanceof WorkspaceView || viewParent instanceof RecyclerView) {
            break;
        }

        leftRelativeToWorkspace += ((View) viewParent).getLeft();
        topRelativeToWorkspace += ((View) viewParent).getTop();

        viewParent = viewParent.getParent();
    }

    if (viewParent == null) {
        throw new IllegalStateException(
                "No WorkspaceView or RecyclerView found among view's parents.");
    }

    viewPosition.x = leftRelativeToWorkspace;
    viewPosition.y = topRelativeToWorkspace;
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:38,代码来源:WorkspaceHelper.java

示例9: onInitializeAccessibilityNodeInfo

import android.view.ViewParent; //导入依赖的package包/类
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();
    info.setClassName(SlidingPaneLayout.class.getName());
    info.setSource(host);
    ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }
    int childCount = SlidingPaneLayout.this.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = SlidingPaneLayout.this.getChildAt(i);
        if (!filter(child) && child.getVisibility() == 0) {
            ViewCompat.setImportantForAccessibility(child, 1);
            info.addChild(child);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:SlidingPaneLayout.java

示例10: setEmptyView

import android.view.ViewParent; //导入依赖的package包/类
public final void setEmptyView(View newEmptyView) {
    FrameLayout refreshableViewWrapper = getRefreshableViewWrapper();
    if (newEmptyView != null) {
        newEmptyView.setClickable(true);
        ViewParent newEmptyViewParent = newEmptyView.getParent();
        if (newEmptyViewParent != null && (newEmptyViewParent instanceof ViewGroup)) {
            ((ViewGroup) newEmptyViewParent).removeView(newEmptyView);
        }
        LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams());
        if (lp != null) {
            refreshableViewWrapper.addView(newEmptyView, lp);
        } else {
            refreshableViewWrapper.addView(newEmptyView);
        }
    }
    if (this.mRefreshableView instanceof EmptyViewMethodAccessor) {
        ((EmptyViewMethodAccessor) this.mRefreshableView).setEmptyViewInternal(newEmptyView);
    } else {
        ((AbsListView) this.mRefreshableView).setEmptyView(newEmptyView);
    }
    this.mEmptyView = newEmptyView;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:PullToRefreshAdapterViewBase.java

示例11: scrollToBar

import android.view.ViewParent; //导入依赖的package包/类
private void scrollToBar(int barIndex, int autoScrollAnimationTime) {
    ViewParent parentView = getParent();
    if (parentView instanceof ScrollView) {
        final ScrollView parentScrollView = (ScrollView) parentView;
        for (View view : views) {
            if (view instanceof SystemView
                    && view.isShown()) {
                SystemView systemView = (SystemView) view;
                if (systemView.containsBar(barIndex)) {
                    int scroll_max = getBottom() - parentScrollView.getHeight();
                    int scroll_min = 0;
                    float windowHeight = parentScrollView.getHeight();
                    float windowPlayingCentre = kWindowPlayingCentreFractionFromTop * windowHeight;
                    float sysFrac = systemView.fractionalScroll(barIndex);
                    float playingCentre = view.getTop() + view.getHeight() * sysFrac;
                    float scroll_y = playingCentre - windowPlayingCentre;

                    if (scroll_y < scroll_min)
                        scroll_y = scroll_min;
                    else if (scroll_y > scroll_max)
                        scroll_y = scroll_max;
                    slowSmoothScrollTo(parentScrollView, (int) scroll_y, autoScrollAnimationTime);
                }
            }
        }
    }
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:28,代码来源:SeeScoreView.java

示例12: childAtPosition

import android.view.ViewParent; //导入依赖的package包/类
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
开发者ID:grzechu92,项目名称:frogment,代码行数:19,代码来源:KeepingFragmentStateTest.java

示例13: onTouchEvent

import android.view.ViewParent; //导入依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
  boolean result = super.onTouchEvent(event);
  if (wxGesture != null) {
    result |= wxGesture.onTouch(this, event);
  }

  ViewParent parent = getParent();
  if(parent != null){
    switch (event.getAction() & MotionEvent.ACTION_MASK){
      case MotionEvent.ACTION_DOWN:
        if(mLines < getLineCount()) {
          //scrollable
          parent.requestDisallowInterceptTouchEvent(true);
        }
        break;
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        parent.requestDisallowInterceptTouchEvent(false);
        break;
    }
  }
  return result;
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:25,代码来源:WXEditText.java

示例14: childAtPosition

import android.view.ViewParent; //导入依赖的package包/类
private static Matcher<View> childAtPosition(
  final Matcher<View> parentMatcher, final int position
) {

  return new TypeSafeMatcher<View>() {
    @Override
    public void describeTo(Description description) {
      description.appendText("Child at position " + position + " in parent ");
      parentMatcher.describeTo(description);
    }

    @Override
    public boolean matchesSafely(View view) {
      ViewParent parent = view.getParent();
      return parent instanceof ViewGroup && parentMatcher.matches(parent)
        && view.equals(((ViewGroup) parent).getChildAt(position));
    }
  };
}
 
开发者ID:Nishant-Pathak,项目名称:MathView,代码行数:20,代码来源:MainActivityTest.java

示例15: onInitializeAccessibilityNodeInfo

import android.view.ViewParent; //导入依赖的package包/类
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    if (DrawerLayout.CAN_HIDE_DESCENDANTS) {
        super.onInitializeAccessibilityNodeInfo(host, info);
    } else {
        AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
        super.onInitializeAccessibilityNodeInfo(host, superNode);
        info.setSource(host);
        ViewParent parent = ViewCompat.getParentForAccessibility(host);
        if (parent instanceof View) {
            info.setParent((View) parent);
        }
        copyNodeInfoNoChildren(info, superNode);
        superNode.recycle();
        addChildrenForAccessibility(info, (ViewGroup) host);
    }
    info.setClassName(DrawerLayout.class.getName());
    info.setFocusable(false);
    info.setFocused(false);
    info.removeAction(AccessibilityActionCompat.ACTION_FOCUS);
    info.removeAction(AccessibilityActionCompat.ACTION_CLEAR_FOCUS);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:22,代码来源:DrawerLayout.java


注:本文中的android.view.ViewParent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。