0

I have an activity with an ImageView that is bigger then the screen so it's inside a ScrollLayout.

I want to create buttons on top this imageView but: - How can I place the buttons on the image if I don't see the whole image? for example, I'm attaching an image that the green color represents the imageView and the red boxes represents the buttons. how can I put all the buttons on the image if it's scrollable?

enter image description here

TheDragoner
  • 273
  • 2
  • 6
  • 17
  • Maybe try one of these links: https://stackoverflow.com/questions/14211484/how-to-place-buttons-over-image-in-android https://stackoverflow.com/questions/7306453/put-a-button-over-an-imageview – MrFisherman Dec 28 '18 at 18:32

1 Answers1

0

You can make both the image and the buttons scrollable by using e.g. a FrameLayout as the direct child of the ScrollView. So your xml would look like this:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <Button .../>

        <Button .../>

        <Button .../>

    </FrameLayout>

</ScrollView>
Ben P.
  • 52,661
  • 6
  • 95
  • 123
  • but how can I put the buttons in custom places? I have an image that has red squares on it, on different places, so I want to create the buttons on top of those red squares. – TheDragoner Dec 28 '18 at 18:55
  • Do you know the pixel coordinates of the red squares? Or are you trying to compute them at runtime? – Ben P. Dec 28 '18 at 21:59
  • I can get the coordinates , but it would be different on different screen resolutions no? – TheDragoner Dec 30 '18 at 08:58