void showFilter(boolean isVisible) { mIsFilterVisible = isVisible; mConstraintSet.clone(mRootView); if (isVisible) { mConstraintSet.clear(mRvFilters.getId(), ConstraintSet.START); mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START); mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END); } else { mConstraintSet.connect(mRvFilters.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.END); mConstraintSet.clear(mRvFilters.getId(), ConstraintSet.END); } ChangeBounds changeBounds = new ChangeBounds(); changeBounds.setDuration(350); changeBounds.setInterpolator(new AnticipateOvershootInterpolator(1.0f)); TransitionManager.beginDelayedTransition(mRootView, changeBounds); mConstraintSet.applyTo(mRootView); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.constraintset_example_main); mRootLayout = (ConstraintLayout) findViewById(R.id.activity_constraintset_example); // Note that this can also be achieved by calling // `mConstraintSetNormal.load(this, R.layout.constraintset_example_main);` // Since we already have an inflated ConstraintLayout in `mRootLayout`, clone() is // faster and considered the best practice. mConstraintSetNormal.clone(mRootLayout); // Load the constraints from the layout where ImageView is enlarged. mConstraintSetBig.load(this, R.layout.constraintset_example_big); if (savedInstanceState != null) { boolean previous = savedInstanceState.getBoolean(SHOW_BIG_IMAGE); if (previous != mShowBigImage) { mShowBigImage = previous; applyConfig(); } } }
item.createView(); parentLayout.addView(item.view); ConstraintSet set = new ConstraintSet(); set.clone(parentLayout); set.connect(item.view.getId(), ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT); set.connect(item.view.getId(), ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT); set.connect(item.view.getId(), ConstraintSet.TOP, (i == 0 ? ConstraintSet.PARENT_ID : alarmItems.get(i - 1).view.getId()), ConstraintSet.BOTTOM); set.applyTo(parentLayout);
@Override protected void convert(BaseViewHolder helper, SmallVideoBean item) { helper.addOnClickListener(R.id.iv_bg); ConstraintSet constraintSet = new ConstraintSet(); constraintSet.clone((ConstraintLayout) helper.itemView); constraintSet.setDimensionRatio(R.id.iv_bg, "H," + DensityUtil.getScreenSize(mContext).x + ":" + DensityUtil.getScreenSize(mContext).y); constraintSet.applyTo((ConstraintLayout) helper.itemView); helper.getView(R.id.iv_bg).setBackgroundResource(R.mipmap.ic_video_drag_bg); helper.setText(R.id.tv_name, item.title + helper.getAdapterPosition()); } });
/** * Shows a vertical line in the program guide to indicate the current time. * It is only visible in the first screen. This method is called every minute. */ private void setCurrentTimeIndication() { // Get the difference between the current time and the given start time. Calculate // from this value in minutes the width in pixels. This will be horizontal offset // for the time indication. If channel icons are shown then we need to add a // the icon width to the offset. final long currentTime = Calendar.getInstance().getTimeInMillis(); final long durationTime = (currentTime - startTime) / 1000 / 60; final int offset = (int) (durationTime * pixelsPerMinute); // Set the left constraint of the time indication so it shows the actual time if (currentTimeIndication != null) { constraintSet.connect(currentTimeIndication.getId(), ConstraintSet.LEFT, constraintLayout.getId(), ConstraintSet.LEFT, offset); constraintSet.connect(currentTimeIndication.getId(), ConstraintSet.START, constraintLayout.getId(), ConstraintSet.START, offset); constraintSet.applyTo(constraintLayout); } }
activity = getActivity(); constraintSet = new ConstraintSet(); constraintSet.clone(constraintLayout);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_con_set); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); second.clone(this, R.layout.second_view); firstSet.clone(this, R.layout.content_main); constraintLayout = (ConstraintLayout) findViewById(R.id.first_view); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // TransitionManager.beginDelayedTransition(constraintLayout); second.applyTo(constraintLayout); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
@Override public void onClick(View view) { // TransitionManager.beginDelayedTransition(constraintLayout); second.applyTo(constraintLayout); } });