Example usage for android.view ViewGroup getChildAt

List of usage examples for android.view ViewGroup getChildAt

Introduction

In this page you can find the example usage for android.view ViewGroup getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:com.microsoft.artcurator.ui.view.SwipeRefreshLayout.java

@Override
public boolean canChildScrollUp() {
    // look at our inner frame and iterate over the children
    ViewGroup inner = (ViewGroup) getChildAt(0);
    View child;//from   ww  w  .  jav  a 2 s . c o  m
    for (int ii = 0; ii < inner.getChildCount(); ii++) {
        child = inner.getChildAt(ii);
        if (child.isShown()) {
            return ViewCompat.canScrollVertically(child, -1);
        }
    }
    return super.canChildScrollUp();
}

From source file:com.adkdevelopment.earthquakesurvival.utils.Utilities.java

/**
 * Makes sliding from the bottom effect on elements in a RecyclerView.
 * @param context from which call is made.
 * @param viewGroup on which to perform the animation.
 *//*from w ww  . ja  v a 2 s.co m*/
public static void animateViewsIn(Context context, ViewGroup viewGroup) {
    if (viewGroup != null) {
        int count = viewGroup.getChildCount();
        float offset = context.getResources().getDimensionPixelSize(R.dimen.offset_y);

        Interpolator interpolator;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            interpolator = AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in);
        } else {
            interpolator = AnimationUtils.loadInterpolator(context, android.R.interpolator.linear);
        }

        // loop over the children setting an increasing translation y but the same animation
        // duration + interpolation
        for (int i = 0; i < count; i++) {
            View view = viewGroup.getChildAt(i);
            view.setVisibility(View.VISIBLE);
            view.setTranslationY(offset);
            view.setAlpha(0.85f);
            // then animate back to natural position
            view.animate().translationY(0f).alpha(1f).setInterpolator(interpolator).setDuration(300L).start();
            // increase the offset distance for the next view
            offset *= 1.5f;
        }
    }
}

From source file:com.owncloud.android.ui.ThemeableSwitchPreference.java

@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
private void findSwitch(ViewGroup viewGroup) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View child = viewGroup.getChildAt(i);

        if (child instanceof Switch) {
            Switch switchView = (Switch) child;

            int color = ThemeUtils.primaryAccentColor();
            int trackColor = Color.argb(77, Color.red(color), Color.green(color), Color.blue(color));

            // setting the thumb color
            DrawableCompat.setTintList(switchView.getThumbDrawable(),
                    new ColorStateList(new int[][] { new int[] { android.R.attr.state_checked }, new int[] {} },
                            new int[] { color, Color.WHITE }));

            // setting the track color
            DrawableCompat.setTintList(switchView.getTrackDrawable(),
                    new ColorStateList(new int[][] { new int[] { android.R.attr.state_checked }, new int[] {} },
                            new int[] { trackColor, Color.parseColor("#4D000000") }));

            break;
        } else if (child instanceof ViewGroup) {
            findSwitch((ViewGroup) child);
        }//from ww w.  j a v a 2  s . co m
    }
}

From source file:cn.zhangls.android.weibo.common.SwipeActivity.java

/**
 * ?//from   ww  w.ja va  2  s.  co m
 */
private void initSwipeBackFinish() {
    SlidingPaneLayout slidingPaneLayout = new SlidingPaneLayout(this);
    //???mOverhangSize0mOverhangSize?????
    //32dp?0
    try {
        //
        Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
        f_overHang.setAccessible(true);
        f_overHang.set(slidingPaneLayout, 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    slidingPaneLayout.setPanelSlideListener(this);
    slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));

    View leftView = new View(this);
    leftView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    slidingPaneLayout.addView(leftView, 0);

    ViewGroup decor = (ViewGroup) getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundColor(getResources().getColor(android.R.color.white));
    decor.removeView(decorChild);
    decor.addView(slidingPaneLayout);
    slidingPaneLayout.addView(decorChild, 1);
}

From source file:com.proma.Nerd.Main_Page.java

public void setFont(ViewGroup group, Typeface font) {
    int count = group.getChildCount();

    View v;//from w  w w . j  a v  a2  s.  c o m
    for (int i = 0; i < count; i++) {
        v = group.getChildAt(i);
        if (v instanceof TextView || v instanceof Button || v instanceof EditText)
            ((TextView) v).setTypeface(font);
        else if (v instanceof ViewGroup)
            setFont((ViewGroup) v, font);
    }
}

From source file:dev.vision.shopping.center.Splash.java

private void overrideFonts(final Context context, final View v) {
    try {/* w  w w  .j  a  v  a 2  s .  c o  m*/
        if (v instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) v;

            for (int i = 0; i < vg.getChildCount(); i++) {
                View child = vg.getChildAt(i);
                overrideFonts(context, child);
            }

        } else if (v instanceof TextView) {
            ((TextView) v)
                    .setTypeface(Typeface.createFromAsset(context.getAssets(), "AvantGardeITCbyBTBook.otf"));
        }

    } catch (Exception e) {
    }
}

From source file:com.oprisnik.navdrawer.NavDrawerActivity.java

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    ViewGroup rootView = (ViewGroup) findViewById(android.R.id.content);
    if (rootView != null) {
        View drawer = rootView.getChildAt(0);
        // setup the drawer layout if we found it
        if (drawer != null && drawer instanceof NavDrawerLayout) {
            setupDrawerLayout((NavDrawerLayout) drawer);
        }/* www .  j ava  2s  . com*/
    }
}

From source file:com.netease.hearttouch.htimagepicker.core.view.photoview.ViewPagerAdapter.java

private void resetPhotoView(View v) {
    if (v instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) v;
        int childCount = vg.getChildCount();
        for (int i = 0; i < childCount; ++i) {
            View subView = vg.getChildAt(i);
            if (subView instanceof HTPhotoView) {
                ((HTPhotoView) subView).resetToInit(true);
            }//from  w  w w .  jav  a 2  s .  co  m
        }
    }
}

From source file:com.hybris.mobile.lib.ui.view.Alert.java

/**
 * Anim the alert and the main view accordingly
 *
 * @param alertView         View Resources to animate
 * @param mainView          ViewGroup resources
 * @param configuration     describes all device configuration information
 * @param translationYAlert Move alert panel to be displayed
 * @param translationYMain  Move main windows screen
 * @param animIn            true animate panel to be displayed else animate panel to hide
 * @return Animated views//from w  ww  .  j a  va2 s. c  om
 */
private static ViewPropertyAnimator animViews(View alertView, final ViewGroup mainView,
        final Configuration configuration, int translationYAlert, int translationYMain, final boolean animIn) {
    long duration = animIn ? DURATION_IN : DURATION_OUT;
    ViewPropertyAnimator viewPropertyAnimator = null;

    if (configuration.isWithAnim()) {
        viewPropertyAnimator = alertView.animate().translationY(translationYAlert).setDuration(duration);

        if (configuration.isShiftContent()) {
            final View viewToResize = mainView.getChildAt(0);

            // Resizing the view after the animation only alert is not on screen otherwise keep size
            viewToResize.animate().translationY(translationYMain).setDuration(duration)
                    .setListener(new AnimatorListenerAdapter() {

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            super.onAnimationEnd(animation);
                            resizeViewHeight(viewToResize, configuration.getHeight(), !animIn,
                                    mainView.getHeight());
                        }
                    });
        }
    } else {
        alertView.setTranslationY(translationYAlert);

        if (configuration.isShiftContent()) {
            final View viewToResize = mainView.getChildAt(0);
            viewToResize.setTranslationY(translationYMain);

            // Resizing the view
            resizeViewHeight(viewToResize, configuration.getHeight(), !animIn, mainView.getHeight());
        }
    }

    return viewPropertyAnimator;
}

From source file:cn.edu.zucc.list.FabAnimation.MorphDialogToFab.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        TransitionValues endValues) {/*from  ww  w  .  ja  va2 s. com*/
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // hide child views (offset down & fade out)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
                            android.R.interpolator.fast_out_linear_in))
                    .start();
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    transition.setDuration(300);
    return transition;
}