Android - How to display another overlay in onTap action of another overlay - java

I am using MapView to display some polygons (zones) as Overlays on the canvas. I extended the class Overlay and now would like to implement the onTap method. After user taps on one of these zones another overlay should be displayed. I would like to define the layout of this overlay as a normal XML layout and than just inflate it and display.
I have already looked on one example called android-mapviewballoons, but it uses itemized overlays which take an Drawable resource and display it on the mapview. This drawable can than be taped. In my case I want my zone (polygon) to be the clickable resource. Can anyone help me please?

Step #1: Implement onTap() in your Overlay and confirm you are getting control when you want to.
Step #2: Adjust your existing layout such that the MapView is in a container that supports Z-axis ordering, like a RelativeLayout
Step #3: In onTap(), add another child to the container (and, eventually, get rid of that child, when appropriate)
Here is a sample app from one of my books demonstrating this with an ItemizedOverlay, but there should be no significant difference for using the technique with a regular Overlay.

Related

Transparency in Background Picture

I want to achive that I have a transparent background BUT with a picture !
So if got this in the XML file of my layout :
android:background="#drawable/wallpaperpic"
Now I want to transparent it so the background menu (f.ex. widgets or app menu) is seeable but also my drawable/wallpaperpic and the rest of my buttons etc are normal (100%).Hopefully I was able to express my self !
My Background : https://amazingpict.com/wp-content/uploads/2015/04/polygon-texture.jpg
I want to have this
WHERE you also can see my background picture a bit
Try to set the alpha property of the view, like:
yourView.serAlpha(10);
If, as I'm guessing now, you have two layouts, one within the other, where the parent layout has the background, you can do this in the child layout:
android:background="#null"
This way, you can see the background, and your elements are intact.
Option 1 is to convert your image to a PNG and add an alpha channel.
Option 2 (which I would recommend) is to have a separate view that acts as your background, and set the alpha property for this view only. You can use a FrameLayout to put this background view underneath your other controls.
In my opinion use TintableBackgroundView.
TintableBackgroundView.
If you launch your activity the normal way, the system will not render anything behind it (i.e. the launcher will be completely gone - it could even remove it from memory).
You'll need to implement your activity as an alert window. This answer has details on how to implement it.

Google Maps Android -- How access default infowindow?

I have a map that shows a few points. If the user searches for a location instead of using their default location, a placemark will show for the searched location as well. This placemark shows the infowindow by default. All of these points are shown on screen (using a bounding box).
However, although I can account for the placemark to be shown on screen inside a bounding box, I am currently unable to make sure its infowindow is completely visible on screen. For example, if the placemark is the northeast-most item, its infowindow will be overflowing off the screen both on the top and the right.
Is there any way to get the infowindow of a marker? I know I can build one out using the CustomWindowAdapter and later access that view, but I don't want to customize it at all, just to be able to access it (and not just be able to call show or hideinfowindow() from the marker).
Ideally, I could get the height and width of the infowindow in pixels and use that to make sure it is always completely shown on screen.
No, you cannot. What you see as "info window" inside the map view is nothing more than a buffered snapshot (or a screen dump if you will) of the view created by your InfoWindowAdapter, meaning it's not a traditional view added to the view hierarchy, rather it's an image shown in the OpenGL context.
Accessing or manipulating this view after showInfoWindow() won't make any difference to what gets displayed on the map, at least until you call showInfoWindow() again to take a new snapshot.
It's the same reason you cannot add a long-click listener to the info window.

Android Multiple Grid Image

I want to do following things:
1-Create a grid(Size is depend on number of image series) of images on one screen
2-When clicked/chosen a image.
3-second grid (Size is depend on number of image series) of images will be on screen.
4-Horizontal Swipe the first screen to next one to display the other grid(i.e remaining images)
5-When clicked/chosen a image on last grid, an image or layout will be on screen.
Similar to the Grid we see in our android Phone's
Any answer truly Appreciated...
Assuming I understand this correctly, you are probably thinking of a GridView, which takes an adapter to populate the grid with images, just like an adapter for a ListView populates the list with Textviews (or whatever you have in your custom adapter layout).
As for the support to select an image to go to another grid (subdirectories of images?) and swiping between various grids, this would be done using Fragments. For the subdirectory stuff, I don't know if there is an API somewhere to help with this, but if not you would need to implement a recursive tree structure: the internal nodes would define a point that can be selected to navigate to the next level, and the external nodes would be the individual images. Selecting an internal node would enter that subdirectory, and selecting an external node would open a second Fragment with the larger view of the image.
This is all a bit vague, but hopefully it gives you a place to start looking around. Read the developer docs on GridViews and Fragments to see if they help at all.

Android Setting Up Splash Screen(Activity) Like Iphone Part2

After getting solution to call my splash activity only one time (Part1 Question), Now i have to set up my splash activity.
On My First Layout i want functionality like this :
Image One <--> Image Two <--> Imgage Three --> Second xml(Activity)
Also on every image their will be a page control that will indicate on which image is currently on layout(Like the attached screenshot)/ or can be any other way to show this.
That Means From Image one i can go to image two on scrolling to right(I can come back to image one on scrolling to left) From Image two i can go to Image Three on scrolling right(I can come back to image 2 from Image three if i scroll to left)But if i scroll to right from Third Image then i should get to my Second Activity and never return back on those images.
i.e
I want to have scroll view having those three images with the page controller then after we scroll down to the third/last image on further scrolling to right i want that my second activity should be loaded and the splash should never come up.
Can any one tell me any idea how this can be done.
To make splash sheet with scroll view and page control & switch to second activity when done scrolling.
I don't want animation i want it to work manually like scrolling/ or any other way to implement this.
Coding will be much appreciated.
To implement scrollable images like shown above use ViewPagerIndicator library given HERE. Its simple to integrate and will take few minutes. All you have to do is read the usage section in given link.
For switching activity on last page, simply implement onPageChangeListener described in link and check for page number.

Change app background

I'm currently making an android app in which I'd like the user to be able to change the background image.
I've got 3 images and a screen where I can choose a picture and a button for applying.
The issue:
I can allow the user to see all images in the way I want, but I don't know how to set the selected image as app background.
What I want to do:
I want the user to click a button, which exports the selected image to "bakgrund.png" in "/res/drawable-mdpi" and replaces the current one. This would allow me to easily integrate the background switcher. Renaming of current files also works.
PS: My current background images are located in /res/drawable-mdpi named 1.png 2.png and 3.png.
Easiest way would be to call the setBackgroundResource(image_id) method on the root layout. Like if you have a LinearLayout which has android:id="#+linear" as the root layout in the layout xml, then this code will help:-
LinearLayout linearLayout=(LinearLayout) findViewById(R.id.linear);
linear.setBackgroundResource(R.drawable.1);//call this in the OnClickListener's OnClick Method
Firstly, you need different themes which has different backgrounds. So you may use this.setTheme method in your Activity.
Indeed I suggest you, two different layout (with different backgrounds but have same components) and using setContentView during onClick.
I hope it solves your issue.

Categories

Resources