you didn't use layout_weight. you shoud use LayoutParams
LinearLayout.LayoutParams (layout_width, layout_height, layout_weight)
If you didn't use a LayoutParams, GLSurfaceView is only displayed on
full screen.
sample code is below.
LinearLayout mLayout = new LinearLayout (this);
mLayout.setOrientation (LinearLayout.VERTICAL);
GLSurfaceView mPreview = new GLSurfaceView(this);
mLayout.addView (mPreview,
new LinearLayout.LayoutParams (
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT,
1.0f));
Button mButton = new Button (this);
mLayout.addView (mButton,
new LinearLayout.LayoutParams (
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT,
1.0f));
On 6월6일, 오후11시49분, Mark Murphy <[email protected]> wrote:
> fortold wrote:
> > Hi experts,
>
> > I have a simple problem which makes me feel like a stupid. I really
> > need help on this.
>
> > I have a SurfaceView which I created with Java code not XML. I created
> > a MediaPlayer which shows its content on that SurfaceView.
>
> > When I use,
>
> > setContentView(mPreview); // where mPreview is a SurfaceView
>
> > The video is played on the screen.
>
> > I need to add two buttons on the screen. So I tried something like
> > this:
>
> > LinearLayout layout = new LinearLayout(this);
> > layout.setOrientation(LinearLayout.VERTICAL);
> > layout.addView(mPreview);
>
> > Button btn = new Button(this);
> > btn.setText("test");
>
> > layout.addView(btn);
>
> > setContentView(layout);
>
> > This did not change anything. Still the video is displayed on full
> > screen and no buttons appear. I am a java programmer both SE and ME.
> > Things are done in this way on Java.
>
> > Does Android have a different approach?
>
> You have not specified the sizes of either the SurfaceView or the Button.
>
> Consider using some LinearLayout.LayoutParams to specify sizes.
>
> --
> Mark Murphy (a Commons
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Development Wiki:http://wiki.andmob.org- 원본 텍스트 숨기기 -
>
> - 원본 텍스트 보기 -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---