Can I Set “android:layout_below” at Runtime Programmatically?

前端 未结 4 2083
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 11:06

Is it possible when creating a RelativeLayout at runtime to set the equivalent of android:layout_below programmatically?

4条回答
  •  执念已碎
    2020-11-27 11:58

    Alternatively you can use the views current layout parameters and modify them:

    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) viewToLayout.getLayoutParams();
    params.addRule(RelativeLayout.BELOW, R.id.below_id);
    

提交回复
热议问题