开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜