本文整理汇总了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));
}
};
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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();
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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());
}
}
示例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)
);
}
示例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);
}
}
}