Android : How to programmatically set layout_constraintRight_toRightOf “parent”

后端 未结 3 640
予麋鹿
予麋鹿 2020-12-02 20:03

I have a view in ConstrainLayout as follows.



        
3条回答
  •  一整个雨季
    2020-12-02 20:44

    constraintSet = new ConstraintSet(); and so on

    Did not work for me anyhow.

    Solved by

      LayoutParams layoutParams = (LayoutParams) viewToChange.getLayoutParams();
        layoutParams.leftToLeft = anotherViewId;
        layoutParams.rightToRight =anotherViewId;
        layoutParams.topToTop = anotherViewId;
        layoutParams.bottomToBottom = anotherViewId;
        layoutParams.startToStart =anotherViewId;
        layoutParams.endToEnd = anotherViewId;
        viewToChange.setLayoutParams(layoutParams);
    

提交回复
热议问题