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


Java View.getParent方法代码示例

本文整理汇总了Java中android.view.View.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java View.getParent方法的具体用法?Java View.getParent怎么用?Java View.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


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

示例1: childAtPosition

import android.view.View; //导入方法依赖的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:privacyidea,项目名称:privacyidea-authenticator,代码行数:19,代码来源:MainActivityTest.java

示例2: getLaunchProviderRecursive

import android.view.View; //导入方法依赖的package包/类
/**
 * Recursively finds the parent of the given child which implements IconLogInfoProvider
 */
public static LaunchSourceProvider getLaunchProviderRecursive(View v) {
    ViewParent parent = null;

    if (v != null) {
        parent = v.getParent();
    } else {
        return null;
    }

    // Optimization to only check up to 5 parents.
    int count = MAXIMUM_VIEW_HIERARCHY_LEVEL;
    while (parent != null && count-- > 0) {
        if (parent instanceof LaunchSourceProvider) {
            return (LaunchSourceProvider) parent;
        } else {
            parent = parent.getParent();
        }
    }
    return null;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:24,代码来源:UserEventDispatcher.java

示例3: refreshStatus

import android.view.View; //导入方法依赖的package包/类
public void refreshStatus(){
    if (container!=null){
        if (flag == Hide){
            container.setVisibility(View.GONE);
            return;
        }
        if (container.getVisibility() != View.VISIBLE)container.setVisibility(View.VISIBLE);
        View view = null;
        switch (flag){
            case ShowMore:view = moreView;break;
            case ShowError:view = errorView;break;
            case ShowNoMore:view = noMoreView;break;
        }
        if (view == null){
            hide();
            return;
        }
        if (view.getParent()==null)container.addView(view);
        for (int i = 0; i < container.getChildCount(); i++) {
            if (container.getChildAt(i) == view)view.setVisibility(View.VISIBLE);
            else container.getChildAt(i).setVisibility(View.GONE);
        }
    }
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:25,代码来源:DefaultEventDelegate.java

示例4: calculateClippingRect

import android.view.View; //导入方法依赖的package包/类
/**
 * Can be used by view that support {@code removeClippedSubviews} property to calculate area that
 * given {@param view} should be clipped to based on the clipping rectangle of it's parent in
 * case when parent is also set to clip it's children.
 *
 * @param view view that we want to calculate clipping rect for
 * @param outputRect where the calculated rectangle will be written
 */
public static void calculateClippingRect(View view, Rect outputRect) {
  ViewParent parent = view.getParent();
  if (parent == null) {
    outputRect.setEmpty();
    return;
  } else if (parent instanceof ReactClippingViewGroup) {
    ReactClippingViewGroup clippingViewGroup = (ReactClippingViewGroup) parent;
    if (clippingViewGroup.getRemoveClippedSubviews()) {
      clippingViewGroup.getClippingRect(sHelperRect);
      // Intersect the view with the parent's rectangle
      // This will result in the overlap with coordinates in the parent space
      if (!sHelperRect.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) {
        outputRect.setEmpty();
        return;
      }
      // Now we move the coordinates to the View's coordinate space
      sHelperRect.offset(-view.getLeft(), -view.getTop());
      sHelperRect.offset(view.getScrollX(), view.getScrollY());
      outputRect.set(sHelperRect);
      return;
    }
  }
  view.getDrawingRect(outputRect);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:33,代码来源:ReactClippingViewGroupHelper.java

示例5: setMenuView

import android.view.View; //导入方法依赖的package包/类
/**
 * Sets the menu view.
 *
 * @param menuView View that becomes the menu view.
 */
public void setMenuView(View menuView) {
    if (menuView.getParent() != null) {
        throw new IllegalStateException("Your menu view already has a parent. Please make sure your menu view does not have a parent.");
    }

    mMenuView = this.findViewWithTag(TAG_MENU);
    if (mMenuView != null) {
        this.removeView(mMenuView);
    }
    mMenuView = menuView;
    mMenuView.setTag(TAG_MENU);
    addView(mMenuView);
    invalidate();
    requestLayout();
}
 
开发者ID:PSD-Company,项目名称:duo-navigation-drawer,代码行数:21,代码来源:DuoDrawerLayout.java

示例6: onWindowAttributesChanged

import android.view.View; //导入方法依赖的package包/类
public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
    // Update window manager if: we have a view, that view is
    // attached to its parent (which will be a RootView), and
    // this activity is not embedded.
    if (mParent == null) {
        View decor = mDecor;
        if (decor != null && decor.getParent() != null) {
            getWindowManager().updateViewLayout(decor, params);
        }
    }
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:12,代码来源:a.java

示例7: replaceView

import android.view.View; //导入方法依赖的package包/类
public static View replaceView(View srcView, int destId) {
    Context context = srcView.getContext();
    ViewGroup viewParent = (ViewGroup) srcView.getParent();
    View destView = LayoutInflater.from(context).inflate(destId, viewParent, false);
    if (destView.getParent() != null) {
        destView.setVisibility(VISIBLE);
    } else {
        viewParent.addView(destView);
    }
    srcView.setVisibility(GONE);
    return destView;
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:13,代码来源:ViewConverter.java

示例8: removeViewFromParent

import android.view.View; //导入方法依赖的package包/类
/**
 * Remove the given view from its parent.
 *
 * @param view view to remove from its parent
 */
private static void removeViewFromParent(final View view) {
    final ViewParent parent = view.getParent();
    if (parent instanceof ViewGroup) {
        ((ViewGroup) parent).removeView(view);
    }
}
 
开发者ID:wayfair,项目名称:brickkit-android,代码行数:12,代码来源:StickyViewBehavior.java

示例9: PHEmptyDataSet

import android.view.View; //导入方法依赖的package包/类
public PHEmptyDataSet(View fatherView){
    super(fatherView.getContext());
    mcontext = fatherView.getContext();
    this.isFirstCreated = false;
    this.msuperGroup = (ViewGroup) fatherView.getParent();
    this.mfatherView = fatherView;
    ViewGroup.LayoutParams mparam = mfatherView.getLayoutParams();
    this.setLayoutParams(mparam);
    this.imageBTN = new ImageView(mcontext);
    this.imageBTN.setId(9527);
    titleV = new TextView(mcontext);
}
 
开发者ID:HeterPu,项目名称:PHEmptyDataSetForAndroid,代码行数:13,代码来源:PHEmptyDataSet.java

示例10: removeFromParent

import android.view.View; //导入方法依赖的package包/类
/**
 * 从View的Parent中移除该View
 *
 * @param view 要移除的View对象
 */
public static void removeFromParent(View view) {
    if (null != view) {
        ViewParent parent = view.getParent();
        if (null != parent && parent instanceof ViewGroup) {
            ((ViewGroup) parent).removeView(view);
        }
    }
}
 
开发者ID:yhyzgn,项目名称:TabPager,代码行数:14,代码来源:ViewUtils.java

示例11: requestDisallowInterceptTouchEvent

import android.view.View; //导入方法依赖的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

示例12: onClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    View editView = (View) view.getParent();
    if (activity.isConnected) {
        View cardView = (View) editView.getParent();
        final int itemPosition = activity.ruleList.getChildLayoutPosition(cardView);
        activity.editRule(activity.rules.get(itemPosition));
    } else {
        Snackbar.make(activity.findViewById(android.R.id.content), R.string.not_connected,
                Snackbar.LENGTH_SHORT).show();
    }
    MainActivity.fadeView(false, editView);
}
 
开发者ID:j4velin,项目名称:HueNotifier,代码行数:14,代码来源:RuleAdapter.java

示例13: onClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    if (view.getId() != R.id.file_browser_list_item_button) {
        throw new IllegalStateException("Unhandled view in onClick: " + view.toString());
    }

    RelativeLayout parent = (RelativeLayout) view.getParent();
    ViewHolder holder = (ViewHolder) parent.getTag();
    ListItem listItem = getItem(holder.position);
    if (mListener != null && listItem != null) {
        mListener.playItems(listItem.getMediaItems());
    }
}
 
开发者ID:stephenmcgruer,项目名称:simple-upnp,代码行数:14,代码来源:FileBrowserAdapter.java

示例14: prepare

import android.view.View; //导入方法依赖的package包/类
@Override
public void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getHeight() - target.getTop();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1),
            ObjectAnimator.ofFloat(target, "scaleX", 0.1f, 0.475f, 1),
            ObjectAnimator.ofFloat(target, "scaleY", 0.1f, 0.475f, 1),
            ObjectAnimator.ofFloat(target, "translationY", distance, -60, 0)
    );
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:12,代码来源:ZoomInUpAnimator.java

示例15: syncFragmentViewState

import android.view.View; //导入方法依赖的package包/类
private void syncFragmentViewState(Fragment fragment) {
    final View view = fragment.getView();
    if(view != null){
        ViewGroup viewGroup = (ViewGroup) view.getParent();
        if (viewGroup != null && viewGroup.getChildAt(viewGroup.getChildCount() - 1) != fragment.getView()) {
            viewGroup.removeView(view);
            viewGroup.addView(view);
        }
    }

}
 
开发者ID:myl2ning,项目名称:fragmentnav,代码行数:12,代码来源:FragmentTaskManager.java


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