I am working in camera flash application.
I am able to start and stop the camera LED.
I am having problemregarding GUI designing of Torch light.
I want to create GUI like FlashLight Zaphrox..
What i guess is :
You can see that when torch button is clicked, the image changes. View only changes when torch button is clicked.
What i tried so far is :
Display display = getWindowManager().getDefaultDisplay();
width = display.getWidth();
height = display.getHeight();
imageView=(ImageView)findViewById(R.id.imageId);
imageView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent me) {
Toast.makeText(ImageClicker.this,me.getRawX()+" "+me.getRawY(), Toast.LENGTH_SHORT).show();
Log.i("View--Width & Height",view.getWidth()+" "+view.getHeight());
Log.i("View -- Measured Width & Height",view.getMeasuredWidth()+" "+view.getMeasuredHeight());
Log.i("Simple X Y Coordiantes",me.getX()+" "+me.getY());
Log.i("Raw Coordinates",me.getRawX()+" "+me.getRawY());
Log.i("Display Matrix",width+" "+height);
return false;
}
});
& the results i got for two different sized emulators are :
For 320×480
09-07 16:32:28.439: INFO/View--Width & Height(2305): 320 43
09-07 16:32:28.439: INFO/View -- Measured Width & Height(2305): 320 43
09-07 16:32:28.449: INFO/Simple X Y Coordiantes(2305): 160.0 21.0
09-07 16:32:28.449: INFO/Raw Coordinates(2305): 160.0 264.0
09-07 16:32:28.449: INFO/Display Matrix(2305): 320 480
For 480×800
09-07 16:33:22.454: INFO/View--Width & Height(410): 480 64
09-07 16:33:22.464: INFO/View -- Measured Width & Height(410): 480 64
09-07 16:33:22.474: INFO/Simple X Y Coordiantes(410): 240.0 31.0
09-07 16:33:22.474: INFO/Raw Coordinates(410): 240.0 437.0
09-07 16:33:22.505: INFO/Display Matrix(410): 480 800
Edited
Tried according to incrediApp’s answer : Code.
But no result yet.
I dont know how to handle such click events.
I want to have the same UI as of Flashlight Zaphrox.
I want to create the same effect in my application.
How can i do that ? Better if one can explain with example.
Create a canvas that catches touch event in particular area(called flag) like –
Now in your activity,override onTouch() for listening to the touch on flag –
Reference: Capture the flag: A tutorial on Android’s Canvas class and Touch event handler