-1

I'm trying to build an app where I have an Image as ImageView which is my background. Now I want to place another Image at a certain position on top of the background. My target is that the user searches in a list of famous places. I already have that list. And i have a button "Map" for every list entry. When the users presses that button it jumps to the map activity.Currently it's just an activity with an imageview of my map. The image of the famous place should be placed at the right position on my background map.

But the problem now is that I want the background image to have several areas where the other image can be added. I don't really know how to define areas and maybe give them id's to place the second image at the right coordinates.

I was searching for days but didn't find any way how to do this. So I apologize in advance, as I'm new to android programming!

Thanks!

See the image for further explanation on what i want to achieve. So if a user searches the place test. And test is at the location x1 I want the image of the pin to be displayed at x1 on the map. And now my problem is on how to get the image coordinates of x1. Concept

DR318
  • 33
  • 5
  • post what you have tried...and it would be help if you post any example explaining your issue. – Iamat8 Mar 14 '16 at 13:40
  • @Mohit well a the moment I just have an imageview.. i don't know how to start – DR318 Mar 14 '16 at 13:50
  • So what is Your goal for this app? Do You want to make something like a gallery? If yes, I think the GridView is what Your looking for.http://javatechig.com/android/android-gridview-example-building-image-gallery-in-android – Opiatefuchs Mar 14 '16 at 13:53
  • @Opiatefuchs i want a background image which would be like a map. And depending on the user input i want to show another image at a certain position on the map. – DR318 Mar 14 '16 at 13:59
  • ok, then You´ll want to do some stuff like for example showing an image from a famous location if user tapps on a special place? – Opiatefuchs Mar 14 '16 at 14:05
  • @Opiatefuchs yes something in that way. But i'd rather have the user search in a list of places. I already have that list. And i have a button "Map" for every list entry. When the users presses that button it jumps to the map activity and the image of the place should be placed at the right position on my background map. – DR318 Mar 14 '16 at 14:11
  • ok, if we´re talking about a real map like google maps, I hope You have done all the stuff with longitudes and latitudes etc. It´s hard to help without having a little idea how Your app is structured, so I think You should post the relevant part of Your map activity (and layout xml)... – Opiatefuchs Mar 14 '16 at 14:15
  • @Opiatefuchs i don't think its relevant i really just have an imageview. No its not google maps and i dont want that. It's more like a fictional map. – DR318 Mar 14 '16 at 14:20
  • @Opiatefuchs look at my concept. Maybe then it's clearer what I want to achieve. – DR318 Mar 14 '16 at 14:34
  • ah, ok. Then You have to add the imageView programmatically for example with a transparent background and the pin as src type. And play around with xy positions....for example http://stackoverflow.com/questions/6535648/how-can-i-dynamically-set-the-position-of-view-in-android – Opiatefuchs Mar 14 '16 at 14:37
  • @Opiatefuchs alright thank you. But is there no way to get the xy positions automatically? Because when i set them manually woudn't i have problems on different screen sizes? – DR318 Mar 14 '16 at 14:54
  • usually, if You set the position with the layoutParams, it should work, but here I am not completely sure. I think You have to test some...... – Opiatefuchs Mar 14 '16 at 15:02

1 Answers1

0

You should use RelativeLayout and put any ImageView you like on this, It would be something like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imageView"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="131dp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imageView2"
            android:layout_below="@+id/imageView"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />
        </RelativeLayout>
    </LinearLayout>
Yahya
  • 706
  • 8
  • 23