Setting up RelativeLayout in java code

后端 未结 3 1907
我寻月下人不归
我寻月下人不归 2021-01-12 05:35

I\'m having a hard time getting two text views to appear on top of each other in my java code. Here\'s the code I\'m experimenting with:

/** Called when the          


        
3条回答
  •  执笔经年
    2021-01-12 05:53

    I don't think you are looking to layout the text1 view below the RelativeLayout since you added all your views to it as children, right? Try removing the first rule; that rule is asking the text view to be below the same view it is in.

    EDIT: Also a help is explicitly setting the id of the view you are laying out relative to.

    So here:

    text1.setId(2);
    p.addRule(RelativeLayout.BELOW,2);
    

提交回复
热议问题