Removing/Adding constraint programmatically in ConstraintLayout

我只是一个虾纸丫 提交于 2019-12-03 05:23:35

I have not worked through your code, but the following illustrates how to break and make the constraint using ConstraintSet.

    ConstraintSet set = new ConstraintSet();
    ConstraintLayout layout;

    layout = (ConstraintLayout) findViewById(R.id.layout);
    set.clone(layout);
    // The following breaks the connection.
    set.clear(R.id.bottomText, ConstraintSet.TOP);
    // Comment out line above and uncomment line below to make the connection.
    // set.connect(R.id.bottomText, ConstraintSet.TOP, R.id.imageView, ConstraintSet.BOTTOM, 0);
    set.applyTo(layout);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!