@Override public void addView(View child, int index, ViewGroup.LayoutParams params) { super.addView(child, index, params); if (child.getTag() == null || (!child.getTag().equals(LOADING) && !child.getTag().equals(EMPTY) && !child.getTag().equals(ERROR))) { contentViews.add(child); } }
protected void addToolbarView(View v) { ConstraintLayout toolbar = findViewById(R.id.myToolBar); if (toolbar != null) { ConstraintLayout.LayoutParams pls = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); v.setLayoutParams(pls); int padding = DimenUtils.dip2px(this, 12); v.setPadding(padding, padding, padding, padding); pls.setMarginEnd(padding); pls.bottomToBottom = ConstraintSet.PARENT_ID; pls.topToTop = ConstraintSet.PARENT_ID; pls.endToEnd = ConstraintSet.PARENT_ID; //pls.gravity = Gravity.END; toolbar.addView(v); } }
focusImageView.setImageDrawable(getResources().getDrawable(R.mipmap.record_focus_icon)); mPreFocusAnimationView = focusImageView; mRootView.addView(focusImageView);
public void addChart(ChartBean cb) { ImageView chartImg = (ImageView) mRootLayout.findViewById(R.id.preview_chart_img); if(cb == null){ if(chartImg == null){ return; }else{ mRootLayout.removeView(chartImg); } }else{ if (chartImg == null) { chartImg = new ImageView(this); chartImg.setId(R.id.preview_chart_img); chartImg.setScaleType(ImageView.ScaleType.CENTER_INSIDE); ConstraintLayout.LayoutParams lp = new ConstraintLayout.LayoutParams(ViewUtils.dip2px(this, 70), ViewUtils.dip2px(this, 70)); //TODO 这里设置成居中,也可以自定义位置,我嫌麻烦,不想弄了 lp.startToStart = R.id.preview_videoview; lp.endToEnd = R.id.preview_videoview; lp.topToTop = R.id.preview_videoview; lp.bottomToBottom = R.id.preview_videoview; chartImg.setLayoutParams(lp); mRootLayout.addView(chartImg); } chartImg.setImageResource(cb.imgRes); } restartPlay(new PreviewRestartParams.Builder() .setIsNotify(true) .build()); }
checkBox.setOnCheckedChangeListener(alarmCheckboxListener); item.createView(); parentLayout.addView(item.view); ConstraintSet set = new ConstraintSet(); set.clone(parentLayout);