Belgi
Belgi

Reputation: 15082

Android: How can I create a layout within a layout ?

In my app I want to have a button that if the user clicks it than a new layout is opened within the current (acually the main) layout. the new layout should not fill all of the screen and parts of the previous layout should be grayed out. Any ideas on how to do this ?

Upvotes: 0

Views: 162

Answers (3)

Rejinderi
Rejinderi

Reputation: 11844

you can use a ViewFlipper to achieve what you want, position the viewflipper where the child views should fit (part of the screen you say)..

Inflate the rest of the "child" layouts from other xml, add them to the flipper and switch between them when you want...

Upvotes: 0

Shreyash Mahajan
Shreyash Mahajan

Reputation: 23606

Follow the answer of SBerg413. And for more information. you can take the relativelayout for the part that you want to hide and display on the button click. And as like SBerg413 answer. you can hide the respective layout and show the layout you want to display. Hope it will help you. Thanks.

Upvotes: 0

Steve Bergamini
Steve Bergamini

Reputation: 14600

You can show a hidden layout within your button's onClick event by calling

view.setVisibility(View.VISIBLE) 

You can also fade out view elements or whole views with

view.setAlpha(75); 
view.setBackgroundColor(Color.GRAY);

Note that "view" in the first example is your layout element.. LinearLayout, RelativeLayout, etc. and in the 2nd example, "view" is the element(s) you're trying to gray out.

Upvotes: 1

Related Questions