简体   繁体   中英

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 ?

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.

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM