Dynamically adding content to RelativeLayout

后端 未结 2 736
滥情空心
滥情空心 2021-01-03 06:13

Since I\'m still just learning Android (and it appears Amazon says it\'ll be 2 months till I get the Hello, Android book) I\'m still playing around with doing simple things.

相关标签:
2条回答
  • 2021-01-03 07:03

    you are creating new relative layout inside function call. So every time new relative layout created and it added in the view when click button . Use common relative layout.

    0 讨论(0)
  • 2021-01-03 07:12

    It looks like you might be adding the view to the root of the layout xml instead of the RelativeLayout.

    You could try:

    RelativeLayout layout = (RelativeLayout)findViewById(R.id.my_layout);
    layout.addView(addIcon());
    
    0 讨论(0)
提交回复
热议问题