clayton33
clayton33

Reputation: 4216

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

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.

Upvotes: 2

Views: 10922

Answers (2)

Pinki
Pinki

Reputation: 21929

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.

Upvotes: 2

timoschloesser
timoschloesser

Reputation: 2802

Please take a look at RelativeLayouts.

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

Upvotes: 9

Related Questions