[Q] Touch sound on FrameLayout? - Android Software Development

I made a simple application, what basically gets the camera image, and applies an overlay on it (nope, it does not save the image, that's not the goal).
There is an AbsoluteLayout, with the FrameLayout (this gets the image from the camera) and an ImageView (this holds the overlay).
Basically I want to add a feature when a user touches the ImageView, a little sound is played. But I did not found any good declaration of this with a wav file placed in res. Is there any?
If yes, what is the proper method of calling it? I don't want to include MediaPlayer if possible!

Never mind, figured out that ontouchevent is continuous and so it will play the sound repeatedly :S
Had to use ImageButton with onClickEvent

Related

Annoying window... can't add rotation and other stuff...

I'm trying to add rotation and that mini-volume thingy to AutoMapa, a Polish GPS application.
The problem is, the window name is along the lines of Automapa10_9944sd_asff... you get the idea? It's long, filled with brackets and other strange characters, and generally, while customization apps will detect it with their usuall "shake" option, the end result is that I can't get rotation and volume to work with this app.
What's the standard procedure in case of such fiddly apps?
Come on guys / gals... please.
Is there any way to use a wildcard perhaps? I'd really like to get this app under control...

[Q] Live Wallpaper Falling Images and Sizes

I am wondering how to take a bitmap image and have it drop vertically from the top of the screen to the bottom and then wrap and do it again. I can only find how to rotate it around a certain access in the help portions. I'm assuming we can use different speeds as well to do the dropping. Also, what sizes need to be set in the hdpi and so forth? It seems that 920x740 is way to big of a picture for that folder and would be a memory hog.
I've not done any wallpapers apps, but typically, to do what you intend, you'd create a thread (class derived from java.lang.Runnable) with a simple loop and a wait timer (call Thread.sleep(). As the loop iterates, send a message to a class derived from android.os.Handler. In the handler, update your coordinates and refresh your view with view.invalidate().
What has it drop? I'm curious how you have your program realize it needs to drop down and then wrap around. All I understand is how to make it rotate around a set axis point.
bearcatext said:
What has it drop? I'm curious how you have your program realize it needs to drop down and then wrap around. All I understand is how to make it rotate around a set axis point.
Click to expand...
Click to collapse
You're thinking at too high level. There is no built in api for falling objects or animating bitmaps, you need to do it yourself.
The way I do it on my doom live wallpaper is to create a java object for each character or projectile I want to draw. The object contains variables for current x and y coordinates on screen and a method to update the position for a new frame.
That makes sense, that is what I was thinking on my drive home today that maybe all it was is setting the x or y coordinates and subtracting or adding depending on how you want it to look. Thanks for the response though I think this is the second time you've helped me out so I appreciate it.

[Q] Mulitple surfaceviews

Hey,
I know that using multiple surfaceviews is not a good idea. With that aside...
I am trying to make an onscreen joystick to add as an option to a game I am working on. I have a tablet so there is a big enough screen for multiple people to play on the one device, but I want to be able to control from joysticks rather than touching the whole of the screen (as you can imagine 4 people would get in each others way).
I am currently using a surfaceView to display the game on and for single player the normal touchscreen is fine, but I dont quite know how to add the joystick version without putting the joystick on the game map (something I want to avoid).
I have created another layout.xml file to handle my second option, and using a relativeLayout I can put the surfaceview between two other controls (like buttons etc). I dont just want to but 4 buttons for left etc, as I want to have vairable speed which a current_touch_position - centre_joystick_position would achieve.
Sorry for the long entry, but I felt like I needed to justify myself.
Any ideas?
Many thanks,
Steaky
So if anyone is in the same situation as me heres how I solved it.
Using RelativeLayout as a base I split the screen into 3 sections - relativeLayout, surfaceView and relativeLayout. I created a Joystick class that extends the class Button (might change to Bitmap in the future, but I'll go into that). Then put this line into the XML wherever I wanted a joystick
Code:
<view class="com.steaky.game_1.Joystick" android:id="@+id/button_JS2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="100dip" android:minWidth="100dip" android:layout_alignParentRight="true"></view>
I used the setOnTouchListener to take the user input and control the cursor.
One problem I encounter was that Buttons only draw when they are no longer being pressed, so the crosshair showing where the user was ressing (and dragging) only updated when the user lifted their finger.

[Q] How to have the same visual position for Portrait and landscape mode

Dear users,
I am writing an app right now, which puts a floating window on top of every thing.
The only problem is, when i rotate the screen to landscape, the position of the window is all messed up.
If the position is here in portrait:
__________
|"-x-----------"|
|"--------------"|
|"--------------"|
|"--------------"|
|"--------------"|
__________
The position will be like this in landscape:
_______________
|"---------x------------"|
|"-----------------------"|
|"-----------------------"|
_______________
And the position needs to be like this:
_______________
|"-x--------------------"|
|"-----------------------"|
|"-----------------------"|
_______________
There is one thing i forgot to mention above:
The position of the window is fully dynamic, that means that the user can reposition the window when he or she wants too.
I really hope someone can help me out with this issue!
Thank you in advance,
Tim
well i would make a separate layout xml in folder layout-land then everything looks like you want it
That's impossible since the position of the window is set programmatically, and there is no way to set it using XML
tim687 said:
That's impossible since the position of the window is set programmatically, and there is no way to set it using XML
Click to expand...
Click to collapse
Then save the view's coordinates as floats relative to the screen width/height instead of dp or pixels and restore that position after the rotation (you only need to multiply it by screen height/width). Like so:
Java:
float posX = getX()/screenWidth;
float posY = getY()/screenHeight;

[Q] Make invisible WebView emit onDraw() event

Hi all
My question will be quite strange but is what I need unfortunately. Basically I need to create an invisible WebView instance (invisible mean not showed inside the activity) and get screenshot from the showed web page every time something change in the page. No problem from get screenshot, the problem is the way to be advised when something change inside the web page currently loaded into my webview. Please note, changes I need to get can be also some images changed "on the fly" by javascript code inside the page, these kind of "events" can no be detected by standard calls like onloadpagefinished or so on (since images changed are preloaded). Another problem can be when images are fully downloaded by the browser but not yet showed in the view (in case of slow CPU per example). Normally I could to easily fix my problem by overriting the onDraw() event of the webview. Every time onDraw() event is emitted mean that something is changed into the view and I need to get new screenshot. Unfortunately my problem is onDraw() event is emitted only if the view is currently visible inside the activity. If the view is "hidden" or "offscreen" as my case the onDraw() event is not emitted since, obviously, doesn't need it. Android views lifecycle explained in the main android developer site show why this happen (the view is set in pause state once out of visible activity part). Now my question is: is there a way to "force" the view to manage onDraw() event as it would be showed but in offscreen mode like my case?
Thank you to all will can help me

Categories

Resources