當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。