RelativeLayout.RIGHT_OF does not work

后端 未结 1 1710
悲&欢浪女
悲&欢浪女 2021-01-24 12:19

I am trying to create a textview and a button programmatically in the existing relative layout. The idea is to put the textview in the left corner of the parentView(relativeLayo

相关标签:
1条回答
  • 2021-01-24 12:54

    For RelativeLayout.LayoutParams rules, 0 means false, and only applies to rules that don't refer to sibling Views, such as CENTER_IN_PARENT. Since you've set your TextView's ID to 0, the RIGHT_OF rule you're adding is being ignored, as false doesn't make sense with that.

    To remedy this, simply set the TextView's ID to any positive int value; e.g., 1.

    0 讨论(0)
提交回复
热议问题