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


Java ViewGroup.getChildAt方法代码示例

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


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

示例1: setupUserView

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 配置Activity。主要配置Activity的用户视图对状态栏和导航栏的留白
 *
 * @param activity Activity对象,不可为空
 * @throws IllegalStateException
 */
private void setupUserView(@NonNull Activity activity) throws IllegalStateException {
    ViewGroup contentViewGroup = (ViewGroup) activity.findViewById(android.R.id.content);
    final int childViewCount = contentViewGroup.getChildCount();
    if (childViewCount == 0) {
        throw new IllegalStateException("Plz invoke setContentView() method first!");
    } else if (childViewCount > 1) {
        throw new IllegalStateException("Plz set one view in SetContentView() or shouldn't use merge tag!!");
    }

    View userView = contentViewGroup.getChildAt(0);
    userView.setFitsSystemWindows(false);
    ViewGroup.MarginLayoutParams userViewParams = (ViewGroup.MarginLayoutParams) userView.getLayoutParams();
    userViewParams.topMargin += ImmerseGlobalConfig.getInstance().getStatusBarHeight();
    if (mActivityConfig.hasNavigtionBar()) {
        if (mActivityConfig.isNavigationAtBottom()) {
            userViewParams.bottomMargin += mActivityConfig.getNavigationBarHeight();
        } else {
            userViewParams.rightMargin += mActivityConfig.getNavigationBarWidth();
        }
    }
    userView.setLayoutParams(userViewParams);
}
 
开发者ID:ls1110924,项目名称:ImmerseMode,代码行数:29,代码来源:TpSbTlNbImmerseMode.java

示例2: findViewAt

import android.view.ViewGroup; //导入方法依赖的package包/类
@Nullable
private View findViewAt(@NonNull final View view, final float x, final float y) {
    if (!view.isShown() || !view.isEnabled() || !isViewAt(view, x, y)) {
        return null;
    }

    if (view instanceof ViewGroup) {
        final float transformedX = x - view.getLeft() - ViewCompat.getTranslationX(view);
        final float transformedY = y - view.getTop() - ViewCompat.getTranslationY(view);

        final ViewGroup viewGroup = (ViewGroup) view;
        final int childCount = viewGroup.getChildCount();
        for (int i = childCount - 1; i >= 0; i--) {
            final View child = viewGroup.getChildAt(i);
            final View foundView = findViewAt(child, transformedX, transformedY);
            if (foundView != null) {
                return foundView;
            }
        }
    }

    return view;
}
 
开发者ID:GlobusLTD,项目名称:recyclerview-android,代码行数:24,代码来源:ClickableViewFinder.java

示例3: setTransparentForDrawerLayout

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    // 内容布局不是 LinearLayout 时,设置padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
        contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
    }

    // 设置属性
    setDrawerLayoutProperty(drawerLayout, contentLayout);
}
 
开发者ID:GuoZhaoHui628,项目名称:SliderStatusBar,代码行数:28,代码来源:StatusBarUtil.java

示例4: findScrollableViewByEvent

import android.view.ViewGroup; //导入方法依赖的package包/类
protected View findScrollableViewByEvent(View content, MotionEvent event, View orgScrollableView) {
    if (content instanceof ViewGroup && event != null) {
        ViewGroup viewGroup = (ViewGroup) content;
        final int childCount = viewGroup.getChildCount();
        PointF point = new PointF();
        for (int i = childCount; i > 0; i--) {
            View child = viewGroup.getChildAt(i - 1);
            if (isTransformedTouchPointInView(viewGroup, child, event.getX(), event.getY(), point)) {
                if (!(child instanceof ViewPager) && isScrollableView(child)) {
                    return child;
                } else {
                    event = MotionEvent.obtain(event);
                    event.offsetLocation(point.x, point.y);
                    return findScrollableViewByEvent(child, event, orgScrollableView);
                }
            }
        }
    }
    return orgScrollableView;
}
 
开发者ID:penghuanliang,项目名称:Rxjava2.0Demo,代码行数:21,代码来源:RefreshContentWrapper.java

示例5: onFinishInflate

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    if (getChildCount() > 1) {
        throw new IllegalArgumentException("only can 1 child in this view");
    } else {
        if (getChildAt(0) instanceof ViewGroup) {
            childViewGroup = (ViewGroup) getChildAt(0);
            if (childViewGroup != null) {
                headView = childViewGroup.getChildAt(0);
            }
        } else {
            throw new IllegalArgumentException("child must be instanceof ViewGroup");
        }
    }
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:17,代码来源:CompatNestedScrollView.java

示例6: bfsAddViewChildren

import android.view.ViewGroup; //导入方法依赖的package包/类
private static void bfsAddViewChildren(List<View> views, View startView) {
    int startIndex = views.size();
    if (!containedBeforeIndex(views, startView, startIndex)) {
        views.add(startView);
        for (int index = startIndex; index < views.size(); index++) {
            View view = (View) views.get(index);
            if (view instanceof ViewGroup) {
                ViewGroup viewGroup = (ViewGroup) view;
                int childCount = viewGroup.getChildCount();
                for (int childIndex = 0; childIndex < childCount; childIndex++) {
                    View child = viewGroup.getChildAt(childIndex);
                    if (!containedBeforeIndex(views, child, startIndex)) {
                        views.add(child);
                    }
                }
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:FragmentTransitionCompat21.java

示例7: showViewGroup

import android.view.ViewGroup; //导入方法依赖的package包/类
private static void showViewGroup(String tag, ViewGroup viewGroup, int deep) {
    StringBuilder tab = new StringBuilder();
    for (int i = 0; i < deep; i++) {
        tab.append("\t\t");
    }
    log(tag, deep + ": " + tab + viewGroup.getClass().getName() + "{");
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View view = viewGroup.getChildAt(i);
        if (view instanceof ViewGroup) {
            showViewGroup(tag, (ViewGroup) view, deep + 1);
        } else {
            log(tag, (deep + 1) + ": " + tab.toString() + "\t\t" + view.getClass().getName());
        }
    }
    log(tag, tab + "\t\t" + "}");
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:17,代码来源:LogUtils.java

示例8: invalidateDisplayListInt

import android.view.ViewGroup; //导入方法依赖的package包/类
private void invalidateDisplayListInt(ViewGroup viewGroup, boolean invalidateThis) {
    for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
        final View view = viewGroup.getChildAt(i);
        if (view instanceof ViewGroup) {
            invalidateDisplayListInt((ViewGroup) view, true);
        }
    }
    if (!invalidateThis) {
        return;
    }
    // we need to force it to become invisible
    if (viewGroup.getVisibility() == View.INVISIBLE) {
        viewGroup.setVisibility(View.VISIBLE);
        viewGroup.setVisibility(View.INVISIBLE);
    } else {
        final int visibility = viewGroup.getVisibility();
        viewGroup.setVisibility(View.INVISIBLE);
        viewGroup.setVisibility(visibility);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:21,代码来源:RecyclerView.java

示例9: setEnabledRecursively

import android.view.ViewGroup; //导入方法依赖的package包/类
private void setEnabledRecursively(@NonNull final View view, final boolean enabled) {
    view.setEnabled(enabled);

    if (view instanceof ViewGroup) {
        final ViewGroup viewGroup = (ViewGroup) view;
        final int childCount = viewGroup.getChildCount();
        for (int index = 0; index < childCount; index++) {
            final View child = viewGroup.getChildAt(index);
            setEnabledRecursively(child, enabled);
        }
    }
}
 
开发者ID:GlobusLTD,项目名称:recyclerview-android,代码行数:13,代码来源:RecursiveEnableBehavior.java

示例10: updateTabLayout

import android.view.ViewGroup; //导入方法依赖的package包/类
private void updateTabLayout() {
    ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0);
    int tabsCount = vg.getChildCount();
    for (int j = 0; j < tabsCount; j++) {
        ViewGroup vgTab = (ViewGroup) vg.getChildAt(j);
        int tabChildsCount = vgTab.getChildCount();
        for (int i = 0; i < tabChildsCount; i++) {
            View tabViewChild = vgTab.getChildAt(i);
            if (tabViewChild instanceof TextView) {
                if (font != null)
                    ((TextView) tabViewChild).setTypeface(font);
            }
        }
    }
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:16,代码来源:VideoDetailsFragment.java

示例11: KeyboardUtil

import android.view.ViewGroup; //导入方法依赖的package包/类
private KeyboardUtil(Activity activity, Window window) {
    this.mActivity = activity;
    this.mWindow = window;
    this.mDecorView = activity.getWindow().getDecorView();
    ViewGroup frameLayout = (ViewGroup) mWindow.getDecorView().findViewById(android.R.id.content);
    if (frameLayout.getChildAt(0) != null) {
        this.mFlag = true;
    }
    this.mContentView = frameLayout.getChildAt(0) != null ? frameLayout.getChildAt(0) : frameLayout;
}
 
开发者ID:AriesHoo,项目名称:TitleBarView,代码行数:11,代码来源:KeyboardUtil.java

示例12: setViewAndChildrenEnabled

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * Disables/Enables a view and all of its child views.
 * Leaves the toolbar enabled at all times.
 *
 * @param view    The view to be disabled/enabled
 * @param enabled True or false, enabled/disabled
 */
private void setViewAndChildrenEnabled(View view, boolean enabled) {
    view.setEnabled(enabled);
    if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View child = viewGroup.getChildAt(i);
            if (child instanceof Toolbar) {
                setViewAndChildrenEnabled(child, true);
            } else {
                setViewAndChildrenEnabled(child, enabled);
            }
        }
    }
}
 
开发者ID:PSD-Company,项目名称:duo-navigation-drawer,代码行数:22,代码来源:DuoDrawerLayout.java

示例13: loadRects

import android.view.ViewGroup; //导入方法依赖的package包/类
private void loadRects(ViewGroup vg) {
    concatenatedLeft = getChildAt(1).getLeft();
    concatenatedTop = getChildAt(1).getTop();
    concatenatedRight = getChildAt(1).getRight();
    cursorParams = (LayoutParams) cursor.getLayoutParams();
    for (int i = 0; i < vg.getChildCount(); i++) {
        if (vg.getChildAt(i) instanceof PinView) {
            PinView v = (PinView) vg.getChildAt(i);
            int type = getType(v);
            if (type != TYPE.DUMMY) {
                v.setBackgroundResource(type);
                childrenRects.add(new PinData(((String) v.getTag()),
                        new Rect(
                                concatenatedLeft
                                        + vg.getLeft()
                                        - (extraHorizontalSpace * (!v
                                        .getTag().toString()
                                        .startsWith("_") ? 2 : 1))
                                        + v.getLeft(), concatenatedTop
                                + vg.getTop() + v.getTop()
                                - extraVerticalSpace,
                                concatenatedTop
                                        + vg.getLeft()
                                        + v.getRight()
                                        + (extraHorizontalSpace * (v
                                        .getTag().toString()
                                        .startsWith("_") ? 2 : 2)),
                                concatenatedTop + vg.getTop()
                                        + v.getBottom()
                                        + extraVerticalSpace), i, type));
            }
        } else if (vg.getChildAt(i) instanceof ViewGroup) {
            loadRects((ViewGroup) vg.getChildAt(i));
        }
    }
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:37,代码来源:PinsColumnContainer.java

示例14: clearPreviousSetting

import android.view.ViewGroup; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int count = decorView.getChildCount();
    if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
        decorView.removeViewAt(count - 1);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
        rootView.setPadding(0, 0, 0, 0);
    }
}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:11,代码来源:StatusBarUtil.java

示例15: displayStickers

import android.view.ViewGroup; //导入方法依赖的package包/类
private void displayStickers(List<Sticker> stickers, ViewGroup stickersContainer) {
    stickersContainer.setVisibility(safeIsEmpty(stickers) ? View.GONE : View.VISIBLE);
    if (safeIsEmpty(stickers)) {
        return;
    }

    if (stickersContainer.getChildCount() == 0) {
        ImageView localView = new ImageView(mContext);
        stickersContainer.addView(localView);
    }

    ImageView imageView = (ImageView) stickersContainer.getChildAt(0);
    Sticker sticker = stickers.get(0);

    boolean horisontal = sticker.getHeight() < sticker.getWidth();
    double proporsion = (double) sticker.getWidth() / (double) sticker.getHeight();

    float finalWidth;
    float finalHeihgt;

    if (horisontal) {
        finalWidth = dpToPx(PREFFERED_STICKER_SIZE, mContext);
        finalHeihgt = (float) (finalWidth / proporsion);
    } else {
        finalHeihgt = dpToPx(PREFFERED_STICKER_SIZE, mContext);
        finalWidth = (float) (finalHeihgt * proporsion);
    }

    imageView.getLayoutParams().height = (int) finalHeihgt;
    imageView.getLayoutParams().width = (int) finalWidth;

    PicassoInstance.with()
            .load(sticker.getPhoto256())
            .into(imageView);

}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:37,代码来源:AttachmentsViewBinder.java


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