List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java
private void displaySpeakersData(SessionDetailModel data) { final ViewGroup speakersGroup = (ViewGroup) getActivity().findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i);/*from w w w .j a va2s .co m*/ } final LayoutInflater inflater = getActivity().getLayoutInflater(); boolean hasSpeakers = false; List<SessionDetailModel.Speaker> speakers = data.getSpeakers(); for (final SessionDetailModel.Speaker speaker : speakers) { String speakerHeader = speaker.getName(); if (!TextUtils.isEmpty(speaker.getCompany())) { speakerHeader += ", " + speaker.getCompany(); } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); final ImageView plusOneIcon = (ImageView) speakerView.findViewById(R.id.gplus_icon_box); final ImageView twitterIcon = (ImageView) speakerView.findViewById(R.id.twitter_icon_box); setUpSpeakerSocialIcon(speaker, twitterIcon, speaker.getTwitterUrl(), UIUtils.TWITTER_COMMON_NAME, UIUtils.TWITTER_PACKAGE_NAME); setUpSpeakerSocialIcon(speaker, plusOneIcon, speaker.getPlusoneUrl(), UIUtils.GOOGLE_PLUS_COMMON_NAME, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); // A speaker may have both a Twitter and GPlus page, only a Twitter page or only a // GPlus page, or neither. By default, align the Twitter icon to the right and the GPlus // icon to its left. If only a single icon is displayed, align it to the right. determineSocialIconPlacement(plusOneIcon, twitterIcon); if (!TextUtils.isEmpty(speaker.getImageUrl()) && mSpeakersImageLoader != null) { mSpeakersImageLoader.loadImage(speaker.getImageUrl(), speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speaker.getAbstract()); if (!TextUtils.isEmpty(speaker.getUrl())) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speaker.getUrl())); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); updateEmptyView(data); }
From source file:com.juick.android.MainActivity.java
private static void restyleViewGroup(ViewGroup view, ColorsTheme.ColorTheme colorTheme, boolean pressed, boolean selected, boolean dontBackground) { ViewGroup parent = view; if (parent.getId() == R.id.navigation_panel) return;//from w ww. j a va2 s. com int childCount = parent.getChildCount(); int background = colorTheme.getBackground(pressed); int foreground = colorTheme.getForeground(pressed); if (selected) { background = calculatePressedBackground(background, foreground); } if (!dontBackground) { boolean skipDraw = false; if ((view instanceof LinearLayout || view instanceof FrameLayout || view instanceof RelativeLayout)) { Context context = view.getContext(); if (context instanceof MainActivity || context instanceof MessagesActivity || context instanceof ThreadActivity) { // no unneeded background in given scrolling activities skipDraw = true; if (view.getBackground() != null) { // but enable for layouts that with color skipDraw = false; } if (!skipDraw && view.getClass().getName().toLowerCase().contains("decorview")) { // given activities manage themselves skipDraw = true; } } } if (!skipDraw) parent.setBackgroundColor(background); } if (view instanceof ListView) dontBackground = true; for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); restyleChildrenOrWidget(child, dontBackground); } }
From source file:com.facebook.litho.MountState.java
private static void mountViewIncrementally(View view, Rect localVisibleRect) { assertMainThread();//from w w w . jav a 2 s. co m if (view instanceof LithoView) { final LithoView lithoView = (LithoView) view; lithoView.performIncrementalMount(localVisibleRect); } else if (view instanceof ViewGroup) { final ViewGroup viewGroup = (ViewGroup) view; for (int i = 0; i < viewGroup.getChildCount(); i++) { final View childView = viewGroup.getChildAt(i); if (localVisibleRect.intersects(childView.getLeft(), childView.getTop(), childView.getRight(), childView.getBottom())) { final Rect rect = ComponentsPools.acquireRect(); rect.set(Math.max(0, localVisibleRect.left - childView.getLeft()), Math.max(0, localVisibleRect.top - childView.getTop()), childView.getWidth() - Math.max(0, childView.getRight() - localVisibleRect.right), childView.getHeight() - Math.max(0, childView.getBottom() - localVisibleRect.bottom)); mountViewIncrementally(childView, rect); ComponentsPools.release(rect); } } } }
From source file:info.tellmetime.TellmetimeActivity.java
/** * Handles changing highlight color via #mSeekBarHighlight. * * @param value indicates exact offset in gradient (SeekBar's max value is equal to #mRainbow width). */// www . ja v a 2 s . c o m @Override public void onProgressChanged(SeekBar seekBar, int value, boolean fromUser) { switch (seekBar.getId()) { case R.id.highlightValue: mHighlightColor = mRainbow.getPixel(value, 0); if (((RadioButton) findViewById(R.id.radio_backlight_highlight)).isChecked()) { float[] highlightHSV = new float[3]; Color.colorToHSV(mHighlightColor, highlightHSV); mBacklightColor = Color.HSVToColor(33, highlightHSV); } if (fromUser) mHighlightPosition = (float) value / seekBar.getMax(); mClockAlgorithm.tickTock(); break; case R.id.minutesSize: mMinutesSize = value; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { FrameLayout minutesIndicators = (FrameLayout) findViewById(R.id.minutes_indicators); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) minutesIndicators .getLayoutParams(); params.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); minutesIndicators.setLayoutParams(params); } ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) { TextView m = (TextView) minutesDots.getChildAt(i); m.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); } break; } mHider.delayedHide(4000); }
From source file:com.xnf.henghenghui.ui.view.PagerSlidingTabStrip.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); ViewGroup tabViewGroup = getTabsLayout(); if (tabViewGroup != null) { // ?????/* w w w .j ava 2s . c o m*/ currentPosition = viewPager != null ? viewPager.getCurrentItem() : 0; // if (!disableViewPager) { // scrollToChild(currentPosition, 0); // ?? // selectedTab(currentPosition); // ?TAB // } // ?tab?Pager for (int w = 0; w < tabViewGroup.getChildCount(); w++) { View itemView = tabViewGroup.getChildAt(w); itemView.setTag(w); itemView.setOnClickListener(this); } } }
From source file:me.xiaopan.psts.PagerSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (allowWidthFull && tabsLayout != null) { View childView;/* w w w . j av a2 s . com*/ for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) { childView = tabsLayout.getChildAt(w); ViewGroup.LayoutParams params = childView.getLayoutParams(); params.width = ViewGroup.LayoutParams.WRAP_CONTENT; childView.setLayoutParams(params); } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) { return; } ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null) { return; } if (tabsLayout.getChildCount() <= 0) { return; } if (tabViews == null) { tabViews = new ArrayList<View>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:com.hynet.mergepay.components.widget.panellayout.ViewDragHelper.java
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) { if (v instanceof ViewGroup) { final ViewGroup group = (ViewGroup) v; final int scrollX = v.getScrollX(); final int scrollY = v.getScrollY(); final int count = group.getChildCount(); // Count backwards - let topmost views consume scroll distance first. for (int i = count - 1; i >= 0; i--) { // TODO: Add versioned support here for transformed views. // This will not work for transformed views in Honeycomb+ final View child = group.getChildAt(i); if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) { return true; }/* w w w . j a va2 s .c o m*/ } } return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy)); }
From source file:info.tellmetime.TellmetimeActivity.java
private void resizeClock() { final LinearLayout mClock = (LinearLayout) findViewById(R.id.clock); // Set width of #mClock layout to the screen's shorter edge size, so clock is not // expanded in landscape mode, but has rather somewhat a square shape. RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); lp.width = mShorterEdge;// ww w . j av a 2s . c om mClock.setLayoutParams(lp); final float mItemSize = mShorterEdge / mClock.getChildCount(); final int mRowMargin = (int) -(mItemSize / 2.2); // Scale text size according to shorter edge and set spacing between rows. for (int i = 0; i < mClock.getChildCount(); i++) { LinearLayout row = (LinearLayout) mClock.getChildAt(i); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams(); params.bottomMargin = mRowMargin; row.setLayoutParams(params); for (int j = 0; j < row.getChildCount(); j++) ((TextView) row.getChildAt(j)).setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemSize); } LinearLayout lastRow = (LinearLayout) mClock.getChildAt(mClock.getChildCount() - 1); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) lastRow.getLayoutParams(); params.bottomMargin = 0; lastRow.setLayoutParams(params); TextView twenty = (TextView) findViewById(R.id.twenty); params = (LinearLayout.LayoutParams) twenty.getLayoutParams(); params.leftMargin = 0; twenty.setLayoutParams(params); // Inflates minutes indicators and attaches them to main view. FrameLayout minutesLayout = (FrameLayout) findViewById(R.id.minutes_indicators); minutesLayout.removeAllViews(); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final boolean isLandscape = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; inflater.inflate(isLandscape ? R.layout.minutes_land : R.layout.minutes_portrait, minutesLayout); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, isLandscape ? FrameLayout.LayoutParams.MATCH_PARENT : FrameLayout.LayoutParams.WRAP_CONTENT); if (!isLandscape) { layoutParams.addRule(RelativeLayout.BELOW, R.id.clock); layoutParams.topMargin = (int) -TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize / 3, getResources().getDisplayMetrics()); } minutesLayout.setLayoutParams(layoutParams); ViewGroup minutesDots = (ViewGroup) findViewById(R.id.minutes_dots); for (int i = 0; i < minutesDots.getChildCount(); i++) ((TextView) minutesDots.getChildAt(i)).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mMinutesSize); }
From source file:de.mrapp.android.validation.AbstractValidateableView.java
/** * Adapts the enable state of all children of a specific view group. * * @param viewGroup/*from w w w .j a v a 2 s .c o m*/ * The view group, whose children's enabled states should be adapted, as an instance of * the class {@link ViewGroup}. The view group may not be null * @param enabled * True, if the children should be enabled, false otherwise */ private void setEnabledOnViewGroup(@NonNull final ViewGroup viewGroup, final boolean enabled) { viewGroup.setEnabled(enabled); for (int i = 0; i < viewGroup.getChildCount(); i++) { View child = viewGroup.getChildAt(i); if (child instanceof ViewGroup) { setEnabledOnViewGroup((ViewGroup) child, enabled); } else { child.setEnabled(enabled); } } }
From source file:de.mrapp.android.validation.AbstractValidateableView.java
/** * Adapts the activated state of all children of a specific view group. * * @param viewGroup//from w ww .ja v a2 s . c o m * The view group, whose children's activated states should be adapted, as an instance * of the class {@link ViewGroup}. The view group may not be null * @param activated * True, if the children should be activated, false otherwise */ private void setActivatedOnViewGroup(@NonNull final ViewGroup viewGroup, final boolean activated) { viewGroup.setActivated(activated); for (int i = 0; i < viewGroup.getChildCount(); i++) { View child = viewGroup.getChildAt(i); if (child instanceof ViewGroup) { setActivatedOnViewGroup((ViewGroup) child, activated); } else { child.setActivated(activated); } } }