How to put elements on top of each other in the same xml layout?

自作多情 提交于 2020-01-21 14:36:59

问题


How can I have more than one button, or a button and a text view in the same location in one layout but one on top of the other?

I want to have a button that is hidden most of the time, but occasionally will have a non intrusive popup that will prompt something. The rest of the time there will be a text view there that is a different size.


回答1:


Please take a look at RelativeLayouts.

They use android:layout_below and android:layout_above to position elements below/above other elements.




回答2:


Use TextView.setVisibility(View.VISIBLE) or TextView.setVisibility(View.GONE) depending on your condition and you may not need to put elements on top of each other in the layout.



来源:https://stackoverflow.com/questions/7888337/how-to-put-elements-on-top-of-each-other-in-the-same-xml-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!