Tag Photos on Android App

I am developing an Android application where a user can take a picture. I want the user to be able to tag this photo. For example, they can touch the screen and mark this position as β€œshoes” or β€œhead”.

Is there a built-in way to get the location of the pixel when the user touches the screen (e.g. an API call or event)? Or is there an easier way to do this?

Note. I'm starting to develop Android, so please explain what is wrong with my question, not just down! That would be much more useful.

+3
source share
1 answer

(, main.xml), ImageView:

<ImageView
    android:id="@+id/photo"
    android:src = "@+drawable/filename"
    android:background="@android:color/transparent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
 />

setOnTouchListener:

setContentView(R.layout.main);
ImageView mView = (ImageView) findViewById(R.id.photo);
mView.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            float x = event.getX();
            float y = event.getY();
        } 
});
+8

All Articles