public class

HChain

extends Chain

 java.lang.Object

androidx.constraintlayout.core.dsl.Helper

androidx.constraintlayout.core.dsl.Chain

↳androidx.constraintlayout.core.dsl.HChain

Gradle dependencies

compile group: 'androidx.constraintlayout', name: 'constraintlayout-core', version: '1.1.0-beta01'

  • groupId: androidx.constraintlayout
  • artifactId: constraintlayout-core
  • version: 1.1.0-beta01

Artifact androidx.constraintlayout:constraintlayout-core:1.1.0-beta01 it located at Google repository (https://maven.google.com/)

Summary

Fields
from Chainreferences, styleMap
from Helperconfig, configMap, name, sideMap, type, typeMap
Constructors
publicHChain(java.lang.String name)

publicHChain(java.lang.String name, java.lang.String config)

Methods
public HChain.HAnchorgetEnd()

Get the end anchor

public HChain.HAnchorgetLeft()

Get the left anchor

public HChain.HAnchorgetRight()

Get the right anchor

public HChain.HAnchorgetStart()

Get the start anchor

public voidlinkToEnd(Constraint.HAnchor anchor)

Connect anchor to End

public voidlinkToEnd(Constraint.HAnchor anchor, int margin)

Connect anchor to End

public voidlinkToEnd(Constraint.HAnchor anchor, int margin, int goneMargin)

Connect anchor to End

public voidlinkToLeft(Constraint.HAnchor anchor)

Connect anchor to Left

public voidlinkToLeft(Constraint.HAnchor anchor, int margin)

Connect anchor to Left

public voidlinkToLeft(Constraint.HAnchor anchor, int margin, int goneMargin)

Connect anchor to Left

public voidlinkToRight(Constraint.HAnchor anchor)

Connect anchor to Right

public voidlinkToRight(Constraint.HAnchor anchor, int margin)

Connect anchor to Right

public voidlinkToRight(Constraint.HAnchor anchor, int margin, int goneMargin)

Connect anchor to Right

public voidlinkToStart(Constraint.HAnchor anchor)

Connect anchor to Start

public voidlinkToStart(Constraint.HAnchor anchor, int margin)

Connect anchor to Start

public voidlinkToStart(Constraint.HAnchor anchor, int margin, int goneMargin)

Connect anchor to Start

from ChainaddReference, addReference, getStyle, referencesToString, setStyle
from Helperappend, convertConfigToMap, getConfig, getId, getType, main, toString
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructors

public HChain(java.lang.String name)

public HChain(java.lang.String name, java.lang.String config)

Methods

public HChain.HAnchor getLeft()

Get the left anchor

Returns:

the left anchor

public void linkToLeft(Constraint.HAnchor anchor)

Connect anchor to Left

Parameters:

anchor: anchor to be connected

public void linkToLeft(Constraint.HAnchor anchor, int margin)

Connect anchor to Left

Parameters:

anchor: anchor to be connected
margin: value of the margin

public void linkToLeft(Constraint.HAnchor anchor, int margin, int goneMargin)

Connect anchor to Left

Parameters:

anchor: anchor to be connected
margin: value of the margin
goneMargin: value of the goneMargin

public HChain.HAnchor getRight()

Get the right anchor

Returns:

the right anchor

public void linkToRight(Constraint.HAnchor anchor)

Connect anchor to Right

Parameters:

anchor: anchor to be connected

public void linkToRight(Constraint.HAnchor anchor, int margin)

Connect anchor to Right

Parameters:

anchor: anchor to be connected
margin: value of the margin

public void linkToRight(Constraint.HAnchor anchor, int margin, int goneMargin)

Connect anchor to Right

Parameters:

anchor: anchor to be connected
margin: value of the margin
goneMargin: value of the goneMargin

public HChain.HAnchor getStart()

Get the start anchor

Returns:

the start anchor

public void linkToStart(Constraint.HAnchor anchor)

Connect anchor to Start

Parameters:

anchor: anchor to be connected

public void linkToStart(Constraint.HAnchor anchor, int margin)

Connect anchor to Start

Parameters:

anchor: anchor to be connected
margin: value of the margin

public void linkToStart(Constraint.HAnchor anchor, int margin, int goneMargin)

Connect anchor to Start

Parameters:

anchor: anchor to be connected
margin: value of the margin
goneMargin: value of the goneMargin

public HChain.HAnchor getEnd()

Get the end anchor

Returns:

the end anchor

public void linkToEnd(Constraint.HAnchor anchor)

Connect anchor to End

Parameters:

anchor: anchor to be connected

public void linkToEnd(Constraint.HAnchor anchor, int margin)

Connect anchor to End

Parameters:

anchor: anchor to be connected
margin: value of the margin

public void linkToEnd(Constraint.HAnchor anchor, int margin, int goneMargin)

Connect anchor to End

Parameters:

anchor: anchor to be connected
margin: value of the margin
goneMargin: value of the goneMargin

Source

/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.constraintlayout.core.dsl;

public class HChain extends Chain {
    public class HAnchor extends Anchor {
        HAnchor(Constraint.HSide side) {
            super(Constraint.Side.valueOf(side.name()));
        }
    }

    private HAnchor mLeft = new HAnchor(Constraint.HSide.LEFT);
    private HAnchor mRight = new HAnchor(Constraint.HSide.RIGHT);
    private HAnchor mStart = new HAnchor(Constraint.HSide.START);
    private HAnchor mEnd = new HAnchor(Constraint.HSide.END);

    public HChain(String name) {
        super(name);
        type = new HelperType(typeMap.get(Type.HORIZONTAL_CHAIN));
    }

    public HChain(String name, String config) {
        super(name);
        this.config = config;
        type = new HelperType(typeMap.get(Type.HORIZONTAL_CHAIN));
        configMap = convertConfigToMap();
        if (configMap.containsKey("contains")) {
            Ref.addStringToReferences(configMap.get("contains"), references);
        }
    }

    /**
     * Get the left anchor
     *
     * @return the left anchor
     */
    public HAnchor getLeft() {
        return mLeft;
    }

    /**
     * Connect anchor to Left
     *
     * @param anchor anchor to be connected
     */
    public void linkToLeft(Constraint.HAnchor anchor) {
        linkToLeft(anchor, 0);
    }

    /**
     * Connect anchor to Left
     *
     * @param anchor anchor to be connected
     * @param margin value of the margin
     */
    public void linkToLeft(Constraint.HAnchor anchor, int margin) {
        linkToLeft(anchor, margin, Integer.MIN_VALUE);
    }

    /**
     * Connect anchor to Left
     *
     * @param anchor anchor to be connected
     * @param margin value of the margin
     * @param goneMargin value of the goneMargin
     */
    public void linkToLeft(Constraint.HAnchor anchor, int margin, int goneMargin) {
        mLeft.mConnection = anchor;
        mLeft.mMargin = margin;
        mLeft.mGoneMargin = goneMargin;
        configMap.put("left", mLeft.toString());
    }

    /**
     * Get the right anchor
     *
     * @return the right anchor
     */
    public HAnchor getRight() {
        return mRight;
    }

    /**
     * Connect anchor to Right
     *
     * @param anchor anchor to be connected
     */
    public void linkToRight(Constraint.HAnchor anchor) {
        linkToRight(anchor, 0);
    }

    /**
     * Connect anchor to Right
     *
     * @param anchor anchor to be connected
     * @param margin value of the margin
     */
    public void linkToRight(Constraint.HAnchor anchor, int margin) {
        linkToRight(anchor, margin, Integer.MIN_VALUE);
    }

    /**
     * Connect anchor to Right
     *
     * @param anchor anchor to be connected
     * @param margin value of the margin
     * @param goneMargin value of the goneMargin
     */
    public void linkToRight(Constraint.HAnchor anchor, int margin, int goneMargin) {
        mRight.mConnection = anchor;
        mRight.mMargin = margin;
        mRight.mGoneMargin = goneMargin;
        configMap.put("right", mRight.toString());
    }

    /**
     * Get the start anchor
     *
     * @return the start anchor
     */
    public HAnchor getStart() {
        return mStart;
    }

    /**
     * Connect anchor to Start
     *
     * @param anchor anchor to be connected
     */
    public void linkToStart(Constraint.HAnchor anchor) {
        linkToStart(anchor, 0);
    }

    /**
     * Connect anchor to Start
     *
     * @param anchor anchor to be connected
     * @param margin value of the margin
     */
    public void linkToStart(Constraint.HAnchor anchor, int margin) {
        linkToStart(anchor, margin, Integer.MIN_VALUE);
    }

    /**
     * Connect anchor to Start
     *
     * @param anchor anchor to be connected
     * @param margin value of the margin
     * @param goneMargin value of the goneMargin
     */
    public void linkToStart(Constraint.HAnchor anchor, int margin, int goneMargin) {
        mStart.mConnection = anchor;
        mStart.mMargin = margin;
        mStart.mGoneMargin = goneMargin;
        configMap.put("start", mStart.toString());
    }

    /**
     * Get the end anchor
     *
     * @return the end anchor
     */
    public HAnchor getEnd() {
        return mEnd;
    }

    /**
     * Connect anchor to End
     *
     * @param anchor anchor to be connected
     */
    public void linkToEnd(Constraint.HAnchor anchor) {
        linkToEnd(anchor, 0);
    }

    /**
     * Connect anchor to End
     *
     * @param anchor anchor to be connected
     * @param margin value of the margin
     */
    public void linkToEnd(Constraint.HAnchor anchor, int margin) {
        linkToEnd(anchor, margin, Integer.MIN_VALUE);
    }

    /**
     * Connect anchor to End
     *
     * @param anchor anchor to be connected
     * @param margin value of the margin
     * @param goneMargin value of the goneMargin
     */
    public void linkToEnd(Constraint.HAnchor anchor, int margin, int goneMargin) {
        mEnd.mConnection = anchor;
        mEnd.mMargin = margin;
        mEnd.mGoneMargin = goneMargin;
        configMap.put("end", mEnd.toString());
    }

}