Question about Button and SurfaceView

by Karthik Ravi Shankar » Fri, 23 Apr 2010 16:23:56 GMT


Sponsored Links
 Hi,

I am trying to use SurfaceView for an app. But I need to add buttons the
canvas as well. Not able to gather much from Android.developer site. Can
anybody post if they have done it or have some ideas ?

Thanks,
Karthik R
Graduate Student
Computer Science Department
UCLA

--



Question about Button and SurfaceView

by Mark Murphy » Fri, 23 Apr 2010 19:33:21 GMT


 


Step #1: Define a RelativeLayout.

Step #2: Put the SurfaceView as a child of the RelativeLayout.

Step #3: Put the Button as a *later* child of the RelativeLayout.

This will cause the Button to appear to "float" on the SurfaceView. See
this project for an example:

 http://github.com/commonsguy/vidtry 

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books 

--


Sponsored Links


Other Threads

1. Drawable issues

Hi,

I am trying to resize an image in a textview (set using imagespan). I
tried using setbounds but the image is not reflected.

OnPreDraw - set the bounds
OnDraw - shows the image in some weird place - the updated position
isn't shown correctly.

Can someone please suggest any other option to resize a drawable ?

-- 

2. OutOfMemoryError: how best to transfer large video files into a byte array?

Apologies for cross-posting with StackOverflow, but I'm getting a bit
desperate. I'll cross-post any final answer too.

Please could anyone suggest an approach for transferring a >2MB video
from a ContentResolver into a Bytestream, without running out of
memory?

See question: 
http://stackoverflow.com/questions/2599305/android-outofmemoryerror-while-uploading-video-how-best-to-chunk

Here's the current code, which throws an OutOfMemoryError on the
byteBuffer.write(buffer, 0, len) line when transferring large videos:

// get bytestream to upload
videoByteArray = getBytesFromFile(cR, fileUriString);

public static byte[] getBytesFromFile(ContentResolver cR, String
fileUriString) throws IOException {
    Uri tempuri = Uri.parse(fileUriString);
    InputStream is = cR.openInputStream(tempuri);
    byte[] b3 = readBytes(is);
    is.close();
    return b3;
}
public static byte[] readBytes(InputStream inputStream) throws
IOException {
    ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
    // this is storage overwritten on each iteration with bytes
    int bufferSize = 1024;
    byte[] buffer = new byte[bufferSize];
    int len = 0;
    while ((len = inputStream.read(buffer)) != -1) {
        byteBuffer.write(buffer, 0, len);
    }
    return byteBuffer.toByteArray();
}

-- 

3. FAT32 file size limited to 2GB

4. save a temporary file to /cache

5. Browser Back Button

6. how to start application in last viewed activity in previous session

7. | WTB | htc hero / qliq......