Android ViewParent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ViewParent class.

This code example shows how to use the following methods:setEGLConfigChooser, setEGLContextClientVersion, setRenderer, getHolder, setZOrderOnTop
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
         
        glView = new GLSurfaceView(this);
        // Create an OpenGL ES 2.0 context. 
        glView.setEGLContextClientVersion(2);
        //rgba_8888 
        glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        // Set the Renderer for drawing on the GLSurfaceView 
        glView.setRenderer(new MyGLRenderer());
         
        setContentView(glView);
         
        //set translucent view 
        glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        // put glView on the top of window 
        glView.setZOrderOnTop(true);
 

6
CodeRank
This code example shows how to use the following methods:getChildVisibleRect
        clip.top = 0;
        clip.right = mParent.getWidth();
        clip.bottom = mParent.getHeight();
 
        final ViewParent parent = mParent.getParent();
        if (parent == null || !parent.getChildVisibleRect(mParent, clip, null)) {
            return false; 
        } 
 
        final int[] coords = mTempCoords;
        mParent.getLocationInWindow(coords);
        final int posX = coords[0] + mPositionX + (int) mHotspotX;
        final int posY = coords[1] + mPositionY + (int) mHotspotY;
 
        return posX >= clip.left && posX <= clip.right &&
                posY >= clip.top && posY <= clip.bottom;
    } 
 
    // x and y are in physical pixels. 
    void moveTo(int x, int y) {
5
CodeRank
This code example shows how to use the following methods:getChildVisibleRect
        clip.top = 0;
        clip.right = mParent.getWidth();
        clip.bottom = mParent.getHeight();
 
        final ViewParent parent = mParent.getParent();
        if (parent == null || !parent.getChildVisibleRect(mParent, clip, null)) {
            return false; 
        } 
 
        final int[] coords = mTempCoords;
        mParent.getLocationInWindow(coords);
        final int posX = coords[0] + mPositionX + (int) mHotspotX;
        final int posY = coords[1] + mPositionY + (int) mHotspotY;
 
        return posX >= clip.left && posX <= clip.right &&
                posY >= clip.top && posY <= clip.bottom;
    } 
 
    // x and y are in physical pixels. 
    void moveTo(int x, int y) {
5
CodeRank
This code example shows how to use the following methods:getParent, getClass
    private ViewParent mActionBarView;
    private Class mActionBarViewClass;
    private Class mAbsActionBarViewClass;
 
    public ActionBarViewWrapper(ViewParent actionBarView) {
        if (!actionBarView.getClass().getName().contains("ActionBarView")) {
            String previousP = actionBarView.getClass().getName();
            actionBarView = actionBarView.getParent();
            String throwP = actionBarView.getClass().getName();
            if (!actionBarView.getClass().getName().contains("ActionBarView")) {
                throw new IllegalStateException("Cannot find ActionBarView for " +
                        "Activity, instead found " + previousP + " and " + throwP);
            } 
        } 
        mActionBarView = actionBarView;
        mActionBarViewClass = actionBarView.getClass();
        mAbsActionBarViewClass = actionBarView.getClass().getSuperclass();
    } 
 
    /** 

4
CodeRank
This code example shows how to use the following methods:getChildVisibleRect
     */ 
    private boolean isSelectionVisible(Rect parentRect) {
        // Rescale first selection rect to be in the same coordinates system 
        final ViewParent parent = mParent.getParent();
        Rect rescaledAnchorRect = new Rect(mAnchorRect);
        parent.getChildVisibleRect(mParent, rescaledAnchorRect, null);
        return Rect.intersects(rescaledAnchorRect, parentRect);
    } 
 
    /** 
     * @return true if the selection menu should be visible in relation to its 
     * parent view. 
     */ 
    private boolean isPositionVisible(Point windowPos, Rect parentRect) {
        return windowPos.y >= parentRect.top &&
            windowPos.y + getMeasuredHeight() <= parentRect.bottom;
    } 
 
    /** 
     * @return visible rectangle of parent view. 
4
CodeRank
This code example shows how to use the following methods:getParent
	public ViewGroup getParentFliper(View view) {
		if (view.getParent() instanceof BaseRealViewSwitcher) {
			return (ViewGroup) view.getParent();
		} else { 
			ViewParent parentView = view.getParent();
			if (parentView != null && parentView.getParent() == null)
				return null; 
			else 
				return getParentFliper((View) parentView);
		} 
 
	} 
 
	private void snapToDestination() { 
 
		final int screenWidth = getWidth();
		// int whichScreen = (getScrollX() + (screenWidth / 5) * 4) / 
		// screenWidth; 
		int whichScreen = 0;
		boolean isOnRight = getScrollX() > screenWidth * mCurrentScreen;
4
CodeRank
This code example shows how to use the following methods:getParent
	public ViewGroup getParentFliper(View view) {
		if (view.getParent() instanceof SmoothFliperView) {
			return (ViewGroup) view.getParent();
		} else { 
			ViewParent parentView = view.getParent();
			if (parentView != null && parentView.getParent() == null)
				return null; 
			else 
				return getParentFliper((View) parentView);
		} 
 
	} 
 
	private void snapToDestination() { 
		final int screenWidth = getWidth();
		final int whichScreen = (getScrollX() + (screenWidth / 2))
				/ screenWidth;
 
		snapToScreen(whichScreen);
	} 
4
CodeRank
This code example shows how to use the following methods:getParent
   * @param view the view whose parent to return 
   * @return the parent of {@code view}, or {@code null} if it has no parent 
   */ 
  @Nullable 
  protected ViewParent getViewParent(ViewParent view) {
    return view.getParent();
  } 
 
  /** 
   * Tests if the first {@code View} is the same as, or somewhere inside the 
   * {@code View} hierarchy of, the second {@code View}. 
   */ 
  public boolean viewIsSameOrDescendant(View child, View parent) {
    Preconditions.checkNotNull(child);
    Preconditions.checkNotNull(parent);
 
    if (child == parent) {
      return true; 
    } 
 
4
CodeRank
This code example shows how to use the following methods:getChildVisibleRect
        clip.top = 0;
        clip.right = mParent.getWidth();
        clip.bottom = mParent.getHeight();
 
        final ViewParent parent = mParent.getParent();
        if (parent == null || !parent.getChildVisibleRect(mParent, clip, null)) {
            return false; 
        } 
 
        final int[] coords = mTempCoords;
        mParent.getLocationInWindow(coords);
        final int posX = coords[0] + mPositionX + (int) mHotspotX;
        final int posY = coords[1] + mPositionY + (int) mHotspotY;
 
        return posX >= clip.left && posX <= clip.right &&
                posY >= clip.top && posY <= clip.bottom;
    } 
 
    // x and y are in physical pixels. 
    void moveTo(int x, int y) {
3
CodeRank
This code example shows how to use the following methods:getParent
	public ViewGroup getParentFliper(View view) {
		if (view.getParent() instanceof BaseRealViewSwitcher) {
			return (ViewGroup) view.getParent();
		} else { 
			ViewParent parentView = view.getParent();
			if (parentView != null && parentView.getParent() == null)
				return null; 
			else 
				return getParentFliper((View) parentView);
		} 
 
	} 
 
	private void snapToDestination() { 
		final int screenHeight = getHeight();
 
		boolean isOnRight = getScrollY() > screenHeight * mCurrentScreen;
		boolean limitToSnap = Math.abs(getScrollY() - screenHeight
				* mCurrentScreen) > ViewConfiguration.get(getContext())
				.getScaledPagingTouchSlop(); 
4
CodeRank

Related Android ViewParent Questions & Answers:

See Code Examples for Android ViewParent Methods: