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

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

@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);
  }
}
 
源代码2 项目: AndroidAnimationExercise   文件: PopupManager.java
public static void showPopupWon(GameState gameState) {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	popupContainer.removeAllViews();

	// popup
	PopupWonView popupWonView = new PopupWonView(Shared.context);
	popupWonView.setGameState(gameState);
	int width = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_won_width);
	int height = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_won_height);
	LayoutParams params = new LayoutParams(width, height);
	params.addRule(RelativeLayout.CENTER_IN_PARENT);
	popupContainer.addView(popupWonView, params);

	// animate all together
	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(popupWonView, "scaleX", 0f, 1f);
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(popupWonView, "scaleY", 0f, 1f);
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
	animatorSet.setDuration(500);
	animatorSet.setInterpolator(new DecelerateInterpolator(2));
	popupWonView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
	animatorSet.start();
}
 
源代码3 项目: Android_accordion_view   文件: AccordionView.java
/***
 * This creates an accordion layout. This is called when the user programatically creates an accordion. 'Without Children' signifies that no UI elements
 * have been added to the body of the accordion yet.
 * @param context
 */
private void initializeViewWithoutChildren(Context context) {
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout accordionLayout = (LinearLayout) inflater.inflate(R.layout.accordion, null);
    partition = accordionLayout.findViewById(R.id.partition);
    heading = (TextView) accordionLayout.findViewById(R.id.heading);
    paragraph = (RelativeLayout) accordionLayout.findViewById(R.id.paragraph_layout);
    dropdownImage = (ImageView) accordionLayout.findViewById(R.id.dropdown_image);
    dropupImage = (ImageView) accordionLayout.findViewById(R.id.dropup_image);
    headingLayout = (LinearLayout) accordionLayout.findViewById(R.id.heading_layout);
    paragraph.removeAllViews();
    removeAllViews();
    paragraphBottomMargin = ((LinearLayout.LayoutParams) paragraph.getLayoutParams()).bottomMargin;
    paragraphTopMargin = ((LinearLayout.LayoutParams) paragraph.getLayoutParams()).topMargin;
    addView(accordionLayout);

}
 
源代码4 项目: memory-game   文件: PopupManager.java
public static void showPopupWon(GameState gameState) {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	popupContainer.removeAllViews();

	// popup
	PopupWonView popupWonView = new PopupWonView(Shared.context);
	popupWonView.setGameState(gameState);
	int width = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_won_width);
	int height = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_won_height);
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height);
	params.addRule(RelativeLayout.CENTER_IN_PARENT);
	popupContainer.addView(popupWonView, params);

	// animate all together
	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(popupWonView, "scaleX", 0f, 1f);
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(popupWonView, "scaleY", 0f, 1f);
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
	animatorSet.setDuration(500);
	animatorSet.setInterpolator(new DecelerateInterpolator(2));
	popupWonView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
	animatorSet.start();
}
 
源代码5 项目: letv   文件: FloatingWindowPlayerView.java
public void loadVipAuthenticationView() {
    LogInfo.log("FloatingWindowPlayer", "该集为VIP剧集,加载开通VIP会员界面");
    if (this.mVipAuthView == null) {
        this.mVipAuthView = new FloatingWindowPlayerVipAuthenticationView(this.mContext);
    }
    this.mVipAuthView.setController(this.mFloatingWindowPlayerController);
    this.mVipAuthView.setVisibility(0);
    RelativeLayout container = (RelativeLayout) findViewById(R.id.view_container);
    container.removeAllViews();
    container.addView(this.mVipAuthView);
}
 
@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);
}
 
源代码7 项目: AndroidAnimationExercise   文件: PopupManager.java
public static void showPopupSettings() {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	popupContainer.removeAllViews();

	// background
	ImageView imageView = new ImageView(Shared.context);
	imageView.setBackgroundColor(Color.parseColor("#88555555"));
	imageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	imageView.setClickable(true);
	popupContainer.addView(imageView);

	// popup
	PopupSettingsView popupSettingsView = new PopupSettingsView(Shared.context);
	int width = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_settings_width);
	int height = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_settings_height);
	LayoutParams params = new LayoutParams(width, height);
	params.addRule(RelativeLayout.CENTER_IN_PARENT);
	popupContainer.addView(popupSettingsView, params);

	// animate all together
	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(popupSettingsView, "scaleX", 0f, 1f);
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(popupSettingsView, "scaleY", 0f, 1f);
	ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 0f, 1f);
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator);
	animatorSet.setDuration(500);
	animatorSet.setInterpolator(new DecelerateInterpolator(2));
	animatorSet.start();
}
 
源代码8 项目: Android_accordion_view   文件: AccordionView.java
/***
 * This function is called when the accordion is added in the XML itself and is used to initialize the various components
 * of the accordion
 * @param context
 */
private void initializeViews(Context context) {

    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout accordionLayout = (LinearLayout) inflater.inflate(R.layout.accordion, null);
    partition = accordionLayout.findViewById(R.id.partition);
    heading = (TextView) accordionLayout.findViewById(R.id.heading);
    paragraph = (RelativeLayout) accordionLayout.findViewById(R.id.paragraph_layout);
    dropdownImage = (ImageView) accordionLayout.findViewById(R.id.dropdown_image);
    dropupImage = (ImageView) accordionLayout.findViewById(R.id.dropup_image);
    headingLayout = (LinearLayout) accordionLayout.findViewById(R.id.heading_layout);
    paragraph.removeAllViews();

    int i;
    children = new View[getChildCount()];
    for (i = 0; i < getChildCount(); i++) {
        children[i] = getChildAt(i);
    }
    removeAllViews();
    for (i = 0; i < children.length; i++) {
        paragraph.addView(children[i]);
    }


    paragraphBottomMargin = ((LinearLayout.LayoutParams) paragraph.getLayoutParams()).bottomMargin;
    paragraphTopMargin = ((LinearLayout.LayoutParams) paragraph.getLayoutParams()).topMargin;

    addView(accordionLayout);


}
 
源代码9 项目: memory-game   文件: PopupManager.java
public static void showPopupSettings() {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	popupContainer.removeAllViews();

	// background
	ImageView imageView = new ImageView(Shared.context);
	imageView.setBackgroundColor(Color.parseColor("#88555555"));
	imageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	imageView.setClickable(true);
	popupContainer.addView(imageView);

	// popup
	PopupSettingsView popupSettingsView = new PopupSettingsView(Shared.context);
	int width = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_settings_width);
	int height = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_settings_height);
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height);
	params.addRule(RelativeLayout.CENTER_IN_PARENT);
	popupContainer.addView(popupSettingsView, params);

	// animate all together
	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(popupSettingsView, "scaleX", 0f, 1f);
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(popupSettingsView, "scaleY", 0f, 1f);
	ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 0f, 1f);
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator);
	animatorSet.setDuration(500);
	animatorSet.setInterpolator(new DecelerateInterpolator(2));
	animatorSet.start();
}
 
@Override
public View getView(View contentView, WenkuReaderPageView pageView) {
    Log.d("MewX", "-- slider getView");
    if (contentView == null)
        contentView = getLayoutInflater().inflate(R.layout.layout_reader_swipe_page, null);

    // prevent memory leak
    final RelativeLayout rl = contentView.findViewById(R.id.page_holder);
    rl.removeAllViews();
    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    rl.addView(pageView, lp);

    return contentView;
}
 
源代码11 项目: GSYVideoPlayer   文件: GSYVideoControlView.java
protected void init(Context context) {
    super.init(context);

    mStartButton = findViewById(R.id.start);
    mTitleTextView = (TextView) findViewById(R.id.title);
    mBackButton = (ImageView) findViewById(R.id.back);
    mFullscreenButton = (ImageView) findViewById(R.id.fullscreen);
    mProgressBar = (SeekBar) findViewById(R.id.progress);
    mCurrentTimeTextView = (TextView) findViewById(R.id.current);
    mTotalTimeTextView = (TextView) findViewById(R.id.total);
    mBottomContainer = (ViewGroup) findViewById(R.id.layout_bottom);
    mTopContainer = (ViewGroup) findViewById(R.id.layout_top);
    mBottomProgressBar = (ProgressBar) findViewById(R.id.bottom_progressbar);
    mThumbImageViewLayout = (RelativeLayout) findViewById(R.id.thumb);
    mLockScreen = (ImageView) findViewById(R.id.lock_screen);

    mLoadingProgressBar = findViewById(R.id.loading);


    if (isInEditMode())
        return;

    if (mStartButton != null) {
        mStartButton.setOnClickListener(this);
    }

    if (mFullscreenButton != null) {
        mFullscreenButton.setOnClickListener(this);
        mFullscreenButton.setOnTouchListener(this);
    }

    if (mProgressBar != null) {
        mProgressBar.setOnSeekBarChangeListener(this);
    }

    if (mBottomContainer != null) {
        mBottomContainer.setOnClickListener(this);
    }

    if (mTextureViewContainer != null) {
        mTextureViewContainer.setOnClickListener(this);
        mTextureViewContainer.setOnTouchListener(this);
    }

    if (mProgressBar != null) {
        mProgressBar.setOnTouchListener(this);
    }

    if (mThumbImageViewLayout != null) {
        mThumbImageViewLayout.setVisibility(GONE);
        mThumbImageViewLayout.setOnClickListener(this);
    }
    if (mThumbImageView != null && !mIfCurrentIsFullscreen && mThumbImageViewLayout != null) {
        mThumbImageViewLayout.removeAllViews();
        resolveThumbImage(mThumbImageView);
    }

    if (mBackButton != null)
        mBackButton.setOnClickListener(this);

    if (mLockScreen != null) {
        mLockScreen.setVisibility(GONE);
        mLockScreen.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentState == CURRENT_STATE_AUTO_COMPLETE ||
                        mCurrentState == CURRENT_STATE_ERROR) {
                    return;
                }
                lockTouchLogic();
                if (mLockClickListener != null) {
                    mLockClickListener.onClick(v, mLockCurScreen);
                }
            }
        });
    }

    if (getActivityContext() != null) {
        mSeekEndOffset = CommonUtil.dip2px(getActivityContext(), 50);
    }
}