开发者

Android: layout problem on starting an activity

开发者 https://www.devze.com 2023-03-10 06:45 出处:网络
I have a layout.. The 70% of it occupies a view then i 开发者_开发问答have a button on the 30% left.. on click of the button, i have an activity that should be displayed only on that 30%. what happene

I have a layout.. The 70% of it occupies a view then i 开发者_开发问答have a button on the 30% left.. on click of the button, i have an activity that should be displayed only on that 30%. what happened is, it displays in full screen since i used startActivity(myIntent)... can anyone help me how to start an activity by getting only a certain portion of the layout and not as a full screen? Thanks you!


You may want to look at the Fragments API.

A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running.

Check this post to use it on android < 3.0: http://mobile.tutsplus.com/tutorials/android/android-compatibility-working-with-fragments/


Activities starts in fullscreen always. You may create layout where 70% of screen will be transparent and 30% of screen will be filled by views.


The question you are asking is may be to hide the required view while starting the activity . so for that just set the visibility of that view as invisible.

so to just hide.

    reqview.setVisibilty(View.INVISIBLE) 

in this case your view will be invisible . but it still takes up space for layout purposes.

     reqview.setVisibilty(View.GONE) 

in this case your view will be invisible . and it doesn't take any space for layout purposes.

may be this help you.


you can give the next activity as transparent activity so that it will be displayed in 30 % of the previous activity.But the problem is that you will not get any event for the remaining 70% actvity. if you want like this then go with the transparent activity. If you want this then look into How do I create a transparent Activity on Android?


TODO

btn1.setVisibility(View.INVISIBLE);

Controls the initial visibility of the view.

Must be one of the following constant values.

Constant Value Description

visible 0 Visible on screen; the default value.

invisible 1 Not displayed, but taken into account during layout (space is left for it).

gone 2 Completely hidden, as if the view had not been added.

This corresponds to the global attribute resource symbol visibility.

Related Methods

 setVisibility(int)
0

精彩评论

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

关注公众号