Negative X offset for SurfaceView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Negative X offset for SurfaceView

Postby philzii » Fri Jun 05, 2009 12:07 pm

Hi,

I'm looking for a way to create a SurfaceView which is larger than the native resolution of the device's screen.
E.g. my screen is 480x320 and I want to create a SurfaceView of 533x320.

I need the surface tio be this size because I want to play video with a res of 800x480 and have it scaled down to 533x320 pixels. So my plan is to have it play in a 533x320 SurfaceView and then have this view shifted in x by 26 pixels to the left which will centre the movie on the screen.

I've tried setting the SurfaceView layout_width="533px" in my xml file but it doesn't work. The surface still only takes up 480x320 pixels as if the width of 533 is clipped to 480 somehow.

Any thoughts?

Thanks,
Phil.
philzii
Freshman
Freshman
 
Posts: 2
Joined: Fri Jun 05, 2009 11:00 am

Top

Postby philzii » Wed Jun 10, 2009 10:38 am

Hi,

I worked out a solution to this. I needed to use an AbsoluteLayout.

E,g, in xml :-

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <AbsoluteLayout ...
  2.  
  3.  
  4.  
  5.    <SurfaceView android:id="@+id/surface"
  6.  
  7.                 android:layout_width="1200px"
  8.  
  9.                 android:layout_height="480px"
  10.  
  11.                 android:layout_x="-400px"
  12.  
  13.                 android:layout_y="0px">
  14.  
  15.     </SurfaceView>
  16.  
  17.  
  18.  
  19. </AbsoluteLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Or in Java :-

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     int w = 1200;
  2.  
  3.     int h = 480;
  4.  
  5.     int x = -400;
  6.  
  7.     int y = 0;
  8.  
  9.  
  10.  
  11.     SurfaceView surface = (SurfaceView)findViewById(R.id.surface);
  12.  
  13.     AbsoluteLayout.LayoutParams p = new AbsoluteLayout.LayoutParams(w, h, x, y);  
  14.  
  15.     surface.setLayoutParams(p);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Cheers,
Phil.
philzii
Freshman
Freshman
 
Posts: 2
Joined: Fri Jun 05, 2009 11:00 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 7 guests