Android Button or onTouchEvent

I'm making an android game with SurfaceView and I need to handle touch events.

I tried onTouchEvent(MotionEvent event) and it worked except for making buttons.

If there is an onTouchFinishEvent() type thing, that would be useful for making a button. Or instead should I use an Android button (with a transparent texture) and if so what's the best way.


Category: java Time: 2016-07-28 Views: 3
Tags: java xml android

Related post

  • Standard Android Button with a different color 2009-10-05

    I'd like to change the color of a standard Android button slightly in order to better match a client's branding. The best way I've found to do this so far is to change the Button's drawable to the following drawable located in res/drawable/red_button

  • Where and/or how to generate custom android button graphic images? 2013-01-15

    I'm creating an app, and I want it to be more colorful and vivid. Though, I'm not an artist or have any drawing talent. Is there someplace online where I can create custom images for my android buttons that can save to a .png file? I'm looking for im

  • Android Button Listener Code Minimize Required 2016-01-20

    i have started development on android application and somehow i have managed to make a button and text on activity and on button click i will change the text on TextView. now the problem is Android button listener code is too long and i want to minim

  • Android button size changes at different devices (width is set to dp) 2016-02-11

    I am designing an app which needs the customized button. I made it by inheriting the Android Button and I set its width to 300dp in the layout xml. However, I found the size of button is changing on different devices. Here are the example: My UI in t

  • How to remove shadow in Text of Android Button but not in Button border? 2016-02-17

    I am trying to remove the default white shadow on Android Button text. I found many solution to remove the shadow in whole button but could not find any solution to remove the shadow in text of Button. --------------Solutions------------- Using this

  • put space between android buttons 2013-08-03

    <Button android:id="@+id/o_pharmacy" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawableLeft="@drawable/p2" android:text="@string/o_pharmacy" android:textSize="

  • Ouya / Android : button mapping bitwise 2013-10-18

    I am programming a game with the Gameplay3d Engine. But the Android site has no gamepad support and that is what I need to port my game to Ouya. So I implemented a simple gamepad support and it supports 2 gamepads. So my problem is that I put the but

  • Android: Button method works only once 2016-01-21

    I'm pretty new to Android's Java (so please don't beat me up) and I have a question to my button action. The called method is running only one time. When I click the button the second time nothing happens anymore. I do not understand why. No errors,

  • Android Button default state 2016-01-28

    Why is Button's default behaviour state_activated="false"? Using this selector it never reaches the last row, it stays on the second line: <selector xmlns:android=""> <item android:dra

  • android button is over listview 2016-01-31

    first, I want to say sorry but i have my problems with designing android app :D I want that the button is below the listview. Actually the button is over the listview and hide the lower region. How can I fix it? My layout file: <FrameLayout xmlns:and

  • Android button place icon on top of it 2016-02-01

    I want to place an image/icon on top of the button how can i reach that same as zindex in css. how can i reach that. Below is a example of my layout file and xml file of the button. Layout File.axml <Button android:text="RTC Alarm" android:te

  • Android button shape in selector doesn't work 2016-02-12

    I have a button and a selector that must change color, padding and corner radius of the button. I have no problems with changing the color, but I can never see any changes with padding and corner radius. button_color.xml <?xml version="1.0" e

  • Android Button are overlapping each other even after setting margin? 2016-02-16

    My layout has two buttons in it and they are getting overlapped over each other i tried adding some margin between them but dint worked. I tried this method but still the button were overlapped i have custom style for my button as below:- <?xml versi

  • android button animation ,activity closes 2016-03-05

    I'm trying to create an app in which on clicking a button, one other button disappears. on implementing it ,the activity closes when the button is clicked(without any errors except E/Surface: getSlotFromBufferLocked: unknown buffer: 0xac1eafc0). Main

  • Android Button Styling in nutshell 2016-03-30

    First I know how to work with button styles, selectors, insets and drawables. My problem is that I can't understand how theming works inside Android. I have concrete example. What I have: <style name="Base.AppTheme" parent="Theme.AppComp

  • Android: Button ripple only shows if there is no background color under it? 2016-02-02

    I have an ImageView with a ripple selector in the top corner of my screen. The ripple will not work for some reason. Please take a look at my image! (I need 10 reps to post an image -_-) View B has a dark green background color. Once I remove this ba

  • android button listener for some combination 2016-02-13

    I m trying to build an app in which I want to use combination of buttons to give input and I want that when user presses multiple buttons then they can press buttons in a gap of 2 sec and then finally I want to write code for the combination of butto

  • Appcelerator Style Button Image Android 2016-02-01

    I have a piece of code which generates the button: var call_buttons = Titanium.UI.createButton({ id: resultNodeID, title: resultNodeTitleNoQuotes + ", " + "Rating: " + ratings, font: { fontSize:23 }, top: 1, left: '3%', width: '94%', h

  • adding xml to button background gives error in android (visual studio IDE) 2016-02-01

    I am trying to give custom style to a android-button in visual studio 2015 through android:background,,, but it gives an error saying "[ERROR] FATAL UNHANDLED EXCEPTION: Android.Views.InflateException: Binary XML file line #1: Error inflating class &

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.421 (s). 13 q(s)