android.widget.RelativeLayout#getChildCount ( )源码实例Demo

下面列出了android.widget.RelativeLayout#getChildCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: RePlugin-GameSdk   文件: HWWebView.java
/**
	 * 显示自定义错误提示页面
	 */
	protected void showErrorPage() {
		webParentView = (RelativeLayout) getParent();

		initErrorPage();
		
		while (webParentView.getChildCount() > 0) {
			webParentView.removeView(mMebView);
		}
		
		refreshLinearLayout.setVisibility(View.VISIBLE);
		
		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
//		lp.addRule(RelativeLayout.CENTER_IN_PARENT);
		webParentView.addView(refreshLinearLayout, 0, lp);
		
		mIsErrorPage = true;
	}
 
源代码2 项目: YCWebView   文件: AppUtils.java
/**
 * view转bitmap
 */
private static Bitmap viewConversionBitmap(View v) {
    int w = v.getWidth();
    int h = 0;
    if (v instanceof LinearLayout){
        LinearLayout linearLayout = (LinearLayout) v;
        for (int i = 0; i < linearLayout.getChildCount(); i++) {
            h += linearLayout.getChildAt(i).getHeight();
        }
    } else if (v instanceof RelativeLayout){
        RelativeLayout relativeLayout = (RelativeLayout) v;
        for (int i = 0; i < relativeLayout.getChildCount(); i++) {
            h += relativeLayout.getChildAt(i).getHeight();
        }
    } else {
        h = v.getHeight();
    }
    Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(bmp);
    //如果不设置canvas画布为白色,则生成透明
    c.drawColor(Color.WHITE);
    v.layout(0, 0, w, h);
    v.draw(c);
    return bmp;
}
 
@Override
public void initializeLargeIcon(RelativeLayout layout, @Nullable Double value) {
  // Remove previous views.
  if (layout.getChildCount() > 0) {
    layout.removeAllViews();
  }
  ImageView largeIcon = new ImageView(layout.getContext());
  layout.addView(
      largeIcon, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  largeIcon.setImageDrawable(getLevelDrawable(largeIcon.getContext()));
  largeIcon.setRotation(0.0f);
  // Icon level depends on type -- we want to pick something in the middle to look reasonable.
  if (behaviorType == TYPE_ACCELEROMETER_SCALE
      || behaviorType == TYPE_ACCELEROMETER_SCALE_ROTATES) {
    // Pick the middle icon
    largeIcon.setImageLevel(2);
  } else if (behaviorType == TYPE_POSITIVE_RELATIVE_SCALE
      || behaviorType == TYPE_RELATIVE_SCALE) {
    // Pick the most exciting icon (the biggest value represented)
    largeIcon.setImageLevel(3);
  }
}
 
源代码4 项目: TelePlus-Android   文件: TabsPagerTitleStrip.java
public void updateCounter(int position, int count, boolean allMuted)
{
    RelativeLayout frame = (RelativeLayout) tabsContainer.getChildAt(position);
    if (frame != null && frame.getChildCount() > 1)
    {
        TextView tv = (TextView) frame.getChildAt(1);
        if (tv != null)
        {
            if (count > 0 && !FeaturedSettings.tabSettings.hideTabsCounters)
            {
                tv.setVisibility(VISIBLE);
                tv.setText(count >= 10000 && FeaturedSettings.tabSettings.limitTabsCounters ? "+9999" : String.format(Locale.getDefault(), "%d", count));
                tv.getBackground().setColorFilter(allMuted ?
                        Theme.getColor(Theme.key_chats_unreadCounterMuted) :
                        Theme.getColor(Theme.key_chats_unreadCounter), PorterDuff.Mode.SRC_IN);
            }
            else
            {
                tv.setVisibility(INVISIBLE);
            }

            tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
            tv.setTextColor(Theme.getColor(Theme.key_chats_unreadCounterText));
            tv.setPadding(AndroidUtilities.dp(FeaturedSettings.tabSettings.chatsTabCounterSize > 10 ? FeaturedSettings.tabSettings.chatsTabCounterSize - 7 : 4), 0,
                    AndroidUtilities.dp(FeaturedSettings.tabSettings.chatsTabCounterSize > 10 ? FeaturedSettings.tabSettings.chatsTabCounterSize - 7 : 4), 0);
        }
    }
}
 
源代码5 项目: TelePlus-Android   文件: TabsPagerTitleStrip.java
public void updateCounter(int position, int count, boolean allMuted)
{
    RelativeLayout frame = (RelativeLayout) tabsContainer.getChildAt(position);
    if (frame != null && frame.getChildCount() > 1)
    {
        TextView tv = (TextView) frame.getChildAt(1);
        if (tv != null)
        {
            if (count > 0 && !FeaturedSettings.tabSettings.hideTabsCounters)
            {
                tv.setVisibility(VISIBLE);
                tv.setText(count >= 10000 && FeaturedSettings.tabSettings.limitTabsCounters ? "+9999" : String.format(Locale.getDefault(), "%d", count));
                tv.getBackground().setColorFilter(allMuted ?
                        Theme.getColor(Theme.key_chats_unreadCounterMuted) :
                        Theme.getColor(Theme.key_chats_unreadCounter), PorterDuff.Mode.SRC_IN);
            }
            else
            {
                tv.setVisibility(INVISIBLE);
            }

            tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
            tv.setTextColor(Theme.getColor(Theme.key_chats_unreadCounterText));
            tv.setPadding(AndroidUtilities.dp(FeaturedSettings.tabSettings.chatsTabCounterSize > 10 ? FeaturedSettings.tabSettings.chatsTabCounterSize - 7 : 4), 0,
                    AndroidUtilities.dp(FeaturedSettings.tabSettings.chatsTabCounterSize > 10 ? FeaturedSettings.tabSettings.chatsTabCounterSize - 7 : 4), 0);
        }
    }
}
 
源代码6 项目: DataLogger   文件: DisplayActivity.java
public void refreshContentLayout() {

        // The toolbar is updated to include a reference to the current location of the device
        getSupportActionBar().setTitle(
                getResources().getString(R.string.toolbar_base_title)
                        + " | @"
                        + SharedPreferencesHelper.getDeviceLocation(this)
        );

        // When the location is not the hand, the visibility of several layouts (file upload,
        // activity selection, data collection switch and label annotation) is GONE
        int visibility = (mDeviceLocation != Constants.DEVICE_LOCATION_HAND) ? View.GONE : View.VISIBLE;
        int[] layoutsId = new int[]{R.id.connectivity_ui,
                R.id.activities_labels_ui,
                R.id.data_collection_ui,
                R.id.label_annotation_ui,
                R.id.label_annotation_timer};

        for (int layoutId : layoutsId) {
            if (layoutId == R.id.data_collection_ui) {
                Button dataCollectionButton = ((Button) findViewById(R.id.ui_data_collection_button));
                if (dataCollectionButton != null)
                    dataCollectionButton.setVisibility(visibility);
            } else {
                RelativeLayout layout = (RelativeLayout) findViewById(layoutId);
                for (int i = 0; i < layout.getChildCount(); i++) {
                    layout.getChildAt(i).setVisibility(visibility);
                }
            }
        }

        mBluetoothButton = (Button) findViewById(R.id.ui_bluetooth_status_button);
        if (mDeviceLocation == Constants.DEVICE_LOCATION_HAND) {
            mBluetoothButton.setVisibility(View.INVISIBLE);
            if (menu != null)
                menu.findItem(R.id.action_pair).setVisible(true);
        } else if (menu != null)
            menu.findItem(R.id.action_pair).setVisible(false);
    }
 
源代码7 项目: letv   文件: ChannelTabPageIndicator.java
public void setCurrentItem(int item) {
    if (this.mViewPager != null) {
        if (item != -1 || this.mSelectedTabIndex != item) {
            this.mSelectedTabIndex = item;
            int tabCount = this.mTabLayout.getChildCount();
            for (int i = 0; i < tabCount; i++) {
                RelativeLayout childLayout = (RelativeLayout) this.mTabLayout.getChildAt(i);
                for (int j = 0; j < childLayout.getChildCount(); j++) {
                    boolean isSelected;
                    if (i == item) {
                        isSelected = true;
                    } else {
                        isSelected = false;
                    }
                    View view = childLayout.getChildAt(j);
                    if (view instanceof TabView) {
                        view.setSelected(isSelected);
                        if (isSelected) {
                            animateToTab(item);
                        }
                    } else {
                        view.setSelected(isSelected);
                    }
                }
            }
            this.mViewPager.setCurrentItem(item, false);
        }
    }
}
 
源代码8 项目: YCWebView   文件: AppUtils.java
/**
 * 截取RelativeLayout
 **/
public static Bitmap getRelativeLayoutBitmap(RelativeLayout relativeLayout) {
    int h = 0;
    Bitmap bitmap;
    for (int i = 0; i < relativeLayout.getChildCount(); i++) {
        h += relativeLayout.getChildAt(i).getHeight();
    }
    // 创建对应大小的bitmap
    bitmap = Bitmap.createBitmap(relativeLayout.getWidth(), h, Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(bitmap);
    relativeLayout.draw(canvas);
    return bitmap;
}
 
源代码9 项目: YCWebView   文件: X5WebUtils.java
/**
 * view转bitmap,如果是截图控件中有scrollView,那么可以取它的子控件LinearLayout或者RelativeLayout
 * @param v                     view
 * @return                      bitmap对象
 */
private static Bitmap viewConversionBitmap(View v) {
    int w = v.getWidth();
    int h = 0;
    if (v instanceof LinearLayout){
        LinearLayout linearLayout = (LinearLayout) v;
        for (int i = 0; i < linearLayout.getChildCount(); i++) {
            h += linearLayout.getChildAt(i).getHeight();
        }
    } else if (v instanceof RelativeLayout){
        RelativeLayout relativeLayout = (RelativeLayout) v;
        for (int i = 0; i < relativeLayout.getChildCount(); i++) {
            h += relativeLayout.getChildAt(i).getHeight();
        }
    } else if (v instanceof CoordinatorLayout){
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) v;
        for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
            h += coordinatorLayout.getChildAt(i).getHeight();
        }
    } else {
        h = v.getHeight();
    }
    Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(bmp);
    //如果不设置canvas画布为白色,则生成透明
    c.drawColor(Color.WHITE);
    v.layout(0, 0, w, h);
    v.draw(c);
    return bmp;
}
 
@Override
public void initializeLargeIcon(RelativeLayout layout, @Nullable Double value) {
  // Remove previous views.
  if (layout.getChildCount() > 0) {
    layout.removeAllViews();
  }
  Context context = layout.getContext();
  ImageViewCanvas largeIcon = new ImageViewCanvas(context);
  layout.addView(
      largeIcon, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  largeIcon.setImageDrawable(
      context.getResources().getDrawable(R.drawable.sound_frequency_drawable));
  largeIcon.setPitch((value != null) ? value : 0);
}
 
源代码11 项目: AndroidAnimationExercise   文件: PopupManager.java
public static void closePopup() {
	final RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	int childCount = popupContainer.getChildCount();
	if (childCount > 0) {
		View background = null;
		View viewPopup = null;
		if (childCount == 1) {
			viewPopup = popupContainer.getChildAt(0);
		} else {
			background = popupContainer.getChildAt(0);
			viewPopup = popupContainer.getChildAt(1);
		}

		AnimatorSet animatorSet = new AnimatorSet();
		ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleX", 0f);
		ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleY", 0f);
		if (childCount > 1) {
			ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(background, "alpha", 0f);
			animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator);
		} else {
			animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
		}
		animatorSet.setDuration(300);
		animatorSet.setInterpolator(new AccelerateInterpolator(2));
		animatorSet.addListener(new AnimatorListenerAdapter() {
			@Override
			public void onAnimationEnd(Animator animation) {
				popupContainer.removeAllViews();
			}
		});
		animatorSet.start();
	}
}
 
源代码12 项目: memory-game   文件: PopupManager.java
public static void closePopup() {
	final RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	int childCount = popupContainer.getChildCount();
	if (childCount > 0) {
		View background = null;
		View viewPopup = null;
		if (childCount == 1) {
			viewPopup = popupContainer.getChildAt(0);
		} else {
			background = popupContainer.getChildAt(0);
			viewPopup = popupContainer.getChildAt(1);
		}

		AnimatorSet animatorSet = new AnimatorSet();
		ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleX", 0f);
		ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(viewPopup, "scaleY", 0f);
		if (childCount > 1) {
			ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(background, "alpha", 0f);
			animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator);
		} else {
			animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
		}
		animatorSet.setDuration(300);
		animatorSet.setInterpolator(new AccelerateInterpolator(2));
		animatorSet.addListener(new AnimatorListenerAdapter() {
			@Override
			public void onAnimationEnd(Animator animation) {
				popupContainer.removeAllViews();
			}
		});
		animatorSet.start();
	}
}
 
源代码13 项目: Pimp_my_Z1   文件: CardStack.java
/**
 * Attempt to modify the convertView instead of inflating a new View for this CardStack.
 * If convertView isn't compatible, it isn't modified.
 *
 * @param convertView view to try reusing
 * @return true on success, false if the convertView is not compatible
 */
private boolean convert(View convertView) {
    // only convert singleton stacks
    if (cards.size() != 1) {
        Log.d("CardsUI", "Can't convert view: amount of cards is " + cards.size());
        return false;
    }

    RelativeLayout container = (RelativeLayout) convertView.findViewById(R.id.stackContainer);
    if (container == null) {
        Log.d("CardsUI", "Can't convert view: can't find stackContainer");
        return false;
    }

    if (container.getChildCount() != 1) {
        Log.d("CardsUI", "Can't convert view: child count is " + container.getChildCount());
        return false;
    }

    // check to see if they're compatible Card types
    Card card = cards.get(0);
    View convertCardView = container.getChildAt(0);

    if (convertCardView == null || convertCardView.getId() != card.getId()) {
        Log.d("CardsUI", String.format("Can't convert view: child Id is 0x%x, card Id is 0x%x", convertCardView.getId(), card.getId()));
        return false;
    }

    if (card.convert(convertCardView))
        return true;

    return false;
}
 
源代码14 项目: AndroidAnimationExercise   文件: PopupManager.java
public static boolean isShown() {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	return popupContainer.getChildCount() > 0;
}
 
源代码15 项目: TvWidget   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    BorderView border = new BorderView(this);
    border.setBackgroundResource(R.drawable.border_highlight);

    main = (RelativeLayout) findViewById(R.id.main);
    border.attachTo(main);

    for (int i = 0; i < main.getChildCount(); i++) {
        main.getChildAt(i).setOnClickListener(this);
    }


}
 
源代码16 项目: memory-game   文件: PopupManager.java
public static boolean isShown() {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	return popupContainer.getChildCount() > 0;
}