Java Code Examples for android.widget.RelativeLayout#removeAllViews()

The following examples show how to use android.widget.RelativeLayout#removeAllViews() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageViewSensorAnimationBehavior.java    From science-journal with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example 2
Source File: PopupManager.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: AccordionView.java    From Android_accordion_view with MIT License 6 votes vote down vote up
/***
 * 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);

}
 
Example 4
Source File: PopupManager.java    From memory-game with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 5
Source File: FloatingWindowPlayerView.java    From letv with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: PitchSensorAnimationBehavior.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 7
Source File: PopupManager.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 8
Source File: AccordionView.java    From Android_accordion_view with MIT License 5 votes vote down vote up
/***
 * 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);


}
 
Example 9
Source File: PopupManager.java    From memory-game with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 10
Source File: Wenku8ReaderActivityV1.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 11
Source File: GSYVideoControlView.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
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);
    }
}