I am developing an Auto-cad App in OpenGLES2.0 in Android.
I want to add the panning functionality.
That's how I achieve this pan function:
[Pan Functionality -- just drag the GLSurfaceview to top, bottom,left and right side using touch event].
I need to add a Scrollable View in GLSurfaceview in android.
When I try to add a scroll view in GLSurfaceView, it will not work.
Then, also I tried to add GLSurfaceview in to the ScrollView.
This method also does not work.
Please suggest me some sample code.
Related
I´m new in android development. I want to create a game where the user needs to quickly drag and drop balls with the finger in the screen to specific locations in order to win.
I don´t know if i can do this with simple ImageViews or i need to use canvas or other thing to draw in the screen.
I have tried to drag and drop an ImageView on top of another ImageView but it does not seem to work very well and i'm hesitating if i need to do it drawing figures instead of using the ImageViews or to do something else.
Please advice. Any help is apreciated. Thank you.
ImageViews are Views designed to hold image drawables, which isn't really needed in your case - you can use a simple View with a color background or implemended onDraw method, you can use an ImageView just as well.
Asfor the drag and drop, what you need is any View with implemented onTouch method so that the view changes its position on screen with ACTION_MOVE touch events.
If you're interested, i have implemented a simple frame layout with drag and drop functionality. My layout requires long-click to start drag, but it can be easily modified so it won't. Check it out at my github page. You can clone the project and run demo activity to see how it works, and start from there.
Im working on an application in which we have a xamarin forms scrollview to which we add several subviews. Each of this subviews has a custom renderer defined in the droid project, as we render some pretty complex objects (adorned text displayed as a elaborated poligon for example).
Now I am required to add pinch zoom for that scrollview (yay me!) is there a practical way to accomplish this?
Thanks for your time.
I have an application that uses SurfaceView do draw content. I wanted to add nice ShowcaseView library to my application which uses getWindow().getDecorView()).addView(...) to draw itself on top of other views and decorations. But in my case it does not draw over my SurfaceView (if I remove it from layout, everything works perfect).
Is it a limitation of Android architecture, or I can tune something in my SurfaceView or fix something in ShowcaseView library?
Update
If I call mySurfaceView.setVisibility(View.INVISIBLE) just before creating ShowcaseView everything works perfect too (except that my main view area is black).
Update 2
I've read about Z-indexes of SurfaceView in documentation. I do not touch them in my code.
SOLUTION
Add setWillNotDraw(false) after calling the super constructor of your SurfaceView.
Other hints regarding surfaceview
It might be helpful to
add the SurfaceView to a Container -e.g. RelativeLayout
call getWindow().getDecorView()).requestTransparentRegion(mySurfaceView); after making your view visible
In my application, I would like to add zoom functionality to my views. Like in an activity I am displaying LinearLayout etc. But as of now what I know a view can be zoomed in only in WebView and not in normal view. After all what I want is to zoom in/zoom out feature similar to WebView in my normal views.
Thanks in advance.
Construct a Custom Layout extending Liner Layout or any other. Override its onDraw function and and provide zooming functionality manually. There are many example at SO for zooming. You can follow them..
This might help:
android pinch zoom
How to apply pinch zoom on Gallery in android?
I'm using OpenGL ES on android 2.3.3 at the minute to render a simple 3D game. I'd like to extend it using the built in gestures library, but I can't find a way to recognise the gestures from a GLSurfaceView as opposed to an android view(I don't have an XML layout is what I'm saying)
Is there any way to either implement an XML layout on top of what I have already, or preferably to implement the gestures library on top of the GLSurfaceview instead.
Thanks.
You can attach a normal onTouchListener to GLSurfaceView, so long as you have an instance of GLSurfaceView (which it sounds like is what you have). This is only really useful if you just want to know the raw x,y coordinates on screen where the user has pressed (e.g to rotate around the y if the user moves their finger left/right across the screen)
For gesture library, which I haven't used myself, you should be able to just place your GLSurfaceView inside a frame layout and then place another view (e.g. linear layout set to match_parent) in the same frame layout so that it completely covers the GLSurfaceView and is on top of it. Attach the gesture library to this view (and obviously make sure it is transparent so people can still see the GLSurfaceView below).
The gesture library has a way of 'stealing' events from the view. See here for details.
Here, here, and here are some examples that should make it clearer.