How do I programmatically remove an existing rule that was defined in XML?

前端 未结 3 1446
刺人心
刺人心 2020-12-01 07:03

I have a linear layout that is contained inside a relative layout. It is set in the XML file to be to the right of another linear layout (this works fine). In some cases I

3条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 07:54

    I think you need to call:

    relativeLayout.updateViewLayout(linearLayoutToMove, layoutParams);

    after changing the LayoutParams.

    In reply to the edit, you can create new LayoutParameters using:

    LinearLayout.LayoutParams = new LinearLayout.LayoutParams(
        LinearLayout.LayoutParams.FILL_PARENT,
        LinearLayout.LayoutParams.FILL_PARENT);

    and then add your new rules. Then, update the layout parameters using the previously mentioned updateViewLayout() method.

提交回复
热议问题