android.support.constraint.ConstraintSet Java Examples

The following examples show how to use android.support.constraint.ConstraintSet. 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: ChartActivity.java    From InteractiveChart with Apache License 2.0 6 votes vote down vote up
/**
 * 数据开始加载
 *
 * @param loadingType 加载框出现类型
 */
public void loadBegin(int loadingType, ProgressBar bar, Chart chart) {
  this.constraintSet.setVisibility(bar.getId(), VISIBLE);
  this.constraintSet.connect(bar.getId(), ConstraintSet.START, chart.getId(),
      ConstraintSet.START, Utils.dpTopx(this, 30));
  this.constraintSet.connect(bar.getId(), ConstraintSet.END, chart.getId(),
      ConstraintSet.END, Utils.dpTopx(this, 30));
  switch (loadingType) {
    case LEFT_LOADING:
      this.constraintSet.clear(bar.getId(), ConstraintSet.END);
      break;
    case RIGHT_LOADING:
      this.constraintSet.clear(bar.getId(), ConstraintSet.START);
      break;
  }
  this.chartLayout.setConstraintSet(constraintSet);
}
 
Example #2
Source File: PairView.java    From justaline-android with Apache License 2.0 6 votes vote down vote up
private LottieAnimationView addNewLottieAnimationView(Animation animation) {
        animationImageView = new LottieAnimationView(getContext());
        animationImageView.setId(R.id.animation_view);
//        animationImageView.enableMergePathsForKitKatAndAbove(true);
        messageContainer.addView(animationImageView);

        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(messageContainer);
        constraintSet.constrainWidth(R.id.animation_view, animation.width);
        constraintSet.constrainHeight(R.id.animation_view, animation.height);
        constraintSet.connect(R.id.animation_view, ConstraintSet.BOTTOM, R.id.message,
                ConstraintSet.TOP,
                getResources().getDimensionPixelSize(R.dimen.pair_animation_margin_bottom));
        constraintSet.connect(R.id.animation_view, ConstraintSet.LEFT, ConstraintSet.PARENT_ID,
                ConstraintSet.LEFT);
        constraintSet.connect(R.id.animation_view, ConstraintSet.RIGHT, ConstraintSet.PARENT_ID,
                ConstraintSet.RIGHT);

        constraintSet.applyTo(messageContainer);

        return animationImageView;
    }
 
Example #3
Source File: DualNavigationMapActivity.java    From graphhopper-navigation-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  setTheme(R.style.Theme_AppCompat_NoActionBar);
  super.onCreate(savedInstanceState);
  initializeViews(savedInstanceState);
  navigationView.initialize(this);
  navigationMapConstraint = new ConstraintSet();
  navigationMapConstraint.clone(dualNavigationMap);
  navigationMapExpandedConstraint = new ConstraintSet();
  navigationMapExpandedConstraint.clone(this, R.layout.activity_dual_navigation_map_expanded);

  constraintChanged = new boolean[] {false};
  launchNavigationFab.setOnClickListener(v -> {
    expandCollapse();
    launchNavigation();
  });
}
 
Example #4
Source File: EndNavigationActivity.java    From graphhopper-navigation-android with MIT License 6 votes vote down vote up
private void launchNavigation() {
  launchNavigationFab.hide();
  drawPaella();
  navigationView.setVisibility(View.VISIBLE);
  int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80, getResources().getDisplayMetrics());
  message.getLayoutParams().height = height;
  ConstraintSet constraintSet = new ConstraintSet();
  constraintSet.clone(endNavigationLayout);
  constraintSet.connect(R.id.message, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, 0);
  constraintSet.connect(R.id.message, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END, 0);
  constraintSet.connect(R.id.message, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START, 0);
  constraintSet.applyTo(endNavigationLayout);
  NavigationViewOptions.Builder options = NavigationViewOptions.builder()
    .navigationListener(this)
    .progressChangeListener(this)
    .directionsRoute(route)
    .shouldSimulateRoute(true);
  navigationView.startNavigation(options.build());
  updateUiPickingUp();
}
 
Example #5
Source File: DualNavigationMapActivity.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
private void expandCollapse() {
  TransitionManager.beginDelayedTransition(dualNavigationMap);
  ConstraintSet constraint;
  if (constraintChanged[0]) {
    constraint = navigationMapConstraint;
  } else {
    constraint = navigationMapExpandedConstraint;
  }
  constraint.applyTo(dualNavigationMap);
  constraintChanged[0] = !constraintChanged[0];
}
 
Example #6
Source File: CustomControlLayoutActivity.java    From android-map-sdk with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(@NonNull NaverMap naverMap) {
    this.<CompassView>findViewById(R.id.compass).setMap(naverMap);
    this.<ZoomControlView>findViewById(R.id.zoom).setMap(naverMap);
    this.<IndoorLevelPickerView>findViewById(R.id.indoor_level_picker).setMap(naverMap);

    ScaleBarView scaleBar = findViewById(R.id.scale_bar);
    scaleBar.setMap(naverMap);

    ConstraintLayout container = findViewById(R.id.container);
    int scaleBarMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin);

    findViewById(R.id.fab).setOnClickListener(v -> {
        boolean right = !scaleBar.isRightToLeftEnabled();

        UiSettings uiSettings = naverMap.getUiSettings();

        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(container);

        if (right) {
            uiSettings.setLogoGravity(Gravity.START | Gravity.BOTTOM);
            constraintSet.connect(R.id.scale_bar, ConstraintSet.END, R.id.fab, ConstraintSet.START);
            constraintSet.setMargin(R.id.scale_bar, ConstraintSet.END, scaleBarMargin);
            constraintSet.clear(R.id.scale_bar, ConstraintSet.START);
        } else {
            uiSettings.setLogoGravity(Gravity.START | Gravity.TOP);
            constraintSet.connect(R.id.scale_bar, ConstraintSet.START, ConstraintSet.PARENT_ID,
                ConstraintSet.START);
            constraintSet.setMargin(R.id.scale_bar, ConstraintSet.START, scaleBarMargin);
            constraintSet.clear(R.id.scale_bar, ConstraintSet.END);
        }

        constraintSet.applyTo(container);

        scaleBar.setRightToLeftEnabled(right);
    });
}
 
Example #7
Source File: ConsumerCreditsFragment.java    From px-android with MIT License 5 votes vote down vote up
private void centerLogo() {
    final ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(creditsLagout);
    constraintSet.connect(logo.getId(), ConstraintSet.LEFT, creditsLagout.getId(), ConstraintSet.LEFT, 0);
    constraintSet.connect(logo.getId(), ConstraintSet.RIGHT, creditsLagout.getId(), ConstraintSet.RIGHT, 0);
    constraintSet.connect(logo.getId(), ConstraintSet.TOP, creditsLagout.getId(), ConstraintSet.TOP, 0);
    constraintSet.connect(logo.getId(), ConstraintSet.BOTTOM, creditsLagout.getId(), ConstraintSet.BOTTOM, 0);
    constraintSet.applyTo(creditsLagout);
}
 
Example #8
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
private void showAnimation() {
    show = true;

    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(this, R.layout.activity_main_animation);

    ChangeBounds transition = new ChangeBounds();
    transition.setInterpolator(new AnticipateInterpolator(1.0f));
    transition.setDuration(1200);

    TransitionManager.beginDelayedTransition(cc1, transition);
    constraintSet.applyTo(cc1);
}
 
Example #9
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
private void revertAnimation() {
    show = false;

    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(this, R.layout.activity_main);

    ChangeBounds transition = new ChangeBounds();
    transition.setInterpolator(new AnticipateInterpolator(1.0f));
    transition.setDuration(1200);

    TransitionManager.beginDelayedTransition(cc1, transition);
    constraintSet.applyTo(cc1);

}
 
Example #10
Source File: ChartConstraintSet.java    From InteractiveChart with Apache License 2.0 4 votes vote down vote up
public ChartConstraintSet(ConstraintSet set) {
  clone(set);
}
 
Example #11
Source File: OverviewActivity.java    From privacy-friendly-food-tracker with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a CheckedCardView from the entry
 *
 * @param e
 * @return
 */
private CardView createCardViewForEntry(DatabaseEntry e) {
    // set up CardView for entry
    CheckableCardView c = new CheckableCardView(this);
    setCardViewOptions(c);

    // set up Layout that gets used inside the CardView
    ConstraintLayout cl = new ConstraintLayout(this);
    ConstraintSet set = new ConstraintSet();


    // set up Textviews for cards
    TextView name = new TextView(this);
    name.setTextSize(TypedValue.COMPLEX_UNIT_PX,
            getResources().getDimension(R.dimen.slide_actions));
    TextView amount = new TextView(this);
    TextView energy = new TextView(this);
    TextView calories = new TextView(this);
    calories.setTextSize(TypedValue.COMPLEX_UNIT_PX,
            getResources().getDimension(R.dimen.slide_actions));
    TextView id = new TextView(this);

    // Each CardView needs an ID to reference in the ConstraintText
    name.setId(View.generateViewId());
    amount.setId(View.generateViewId());
    energy.setId(View.generateViewId());
    calories.setId(View.generateViewId());
    id.setText(e.id);

    name.setText(e.name);
    amount.setText(Integer.toString(e.amount) + "g");
    energy.setText(String.format(Locale.ENGLISH, "   %.2f kCal/100g", e.energy));
    calories.setText(String.format(Locale.ENGLISH, "%.2f kCal", getConsumedCaloriesForEntry(e)));
    // id is just an invisible attribute on each card
    id.setVisibility(View.INVISIBLE);

    set.constrainWidth(amount.getId(), ConstraintSet.WRAP_CONTENT);
    set.constrainHeight(amount.getId(), ConstraintSet.WRAP_CONTENT);
    set.constrainWidth(energy.getId(), ConstraintSet.WRAP_CONTENT);
    set.constrainHeight(energy.getId(), ConstraintSet.WRAP_CONTENT);
    set.constrainWidth(calories.getId(), ConstraintSet.WRAP_CONTENT);

    cl.addView(name);
    cl.addView(calories);
    cl.addView(amount);
    cl.addView(energy);
    c.addView(cl);
    c.addView(id);


    set.connect(name.getId(), ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT, 20);
    set.connect(name.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, 20);
    set.connect(name.getId(), ConstraintSet.RIGHT, calories.getId(), ConstraintSet.LEFT, 40);
    set.constrainDefaultHeight(name.getId(), ConstraintSet.MATCH_CONSTRAINT_WRAP);


    set.connect(calories.getId(), ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT, 20);
    set.connect(calories.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP, 20);
    set.constrainDefaultHeight(calories.getId(), ConstraintSet.MATCH_CONSTRAINT_WRAP);
    set.constrainDefaultWidth(calories.getId(), ConstraintSet.MATCH_CONSTRAINT_WRAP);


    set.connect(amount.getId(), ConstraintSet.TOP, name.getId(), ConstraintSet.BOTTOM, 20);
    set.connect(amount.getId(), ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT, 20);
    set.connect(amount.getId(), ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, 20);

    set.connect(energy.getId(), ConstraintSet.TOP, name.getId(), ConstraintSet.BOTTOM, 20);
    set.connect(energy.getId(), ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT, 20);
    set.connect(energy.getId(), ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, 20);

    set.applyTo(cl);

    setListenersForCardView(c, e);
    return c;
}
 
Example #12
Source File: InstructionView.java    From graphhopper-navigation-android with MIT License 4 votes vote down vote up
private void updateLandscapeConstraintsTo(int layoutRes) {
  ConstraintSet collapsed = new ConstraintSet();
  collapsed.clone(getContext(), layoutRes);
  collapsed.applyTo(instructionLayout);
}
 
Example #13
Source File: TransitionActivity.java    From layout-pancake with MIT License 4 votes vote down vote up
private void transitionTo(ConstraintSet constraintSet) {
    TransitionManager.beginDelayedTransition(mConstraintLayout);
    constraintSet.applyTo(mConstraintLayout);
}