Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Scrollable (horizontal and vertical) ImageView with Buttons overlayed
    text
    copied!<p>I want to implement an activity where the only thing you see is a big image, which can be scrolled horizontally and vertically.On Top of that image I want to display buttons, that can be clicked and trigger certain actions (like creating an intent to start a new activity).</p> <p>First I was thinking about a ScrollView, that has a FrameLayout as a child. The FrameLayout could have the image as a background and can have the buttons as childs. Because I know the position of my buttons exactly I could place them with absolute coordinates. Here is my first code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;FrameLayout android:layout_width="1298px" android:layout_height="945px" android:background="@drawable/myimage"&gt; &lt;Button android:id="@+id/mybutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="115px" android:layout_y="128px"/&gt; &lt;/FrameLayout&gt; &lt;/ScrollView&gt; </code></pre> <p>The Problem is, that you can only scroll a ScrollView vertically. HorizontalScrollView doesn't solve the Problem, cause it only scrolls in one direction either. Can I mix them somehow? Is there another solution? </p> <p>I found some similar threads on stackoverflow, where people put the image into a WebView and get horizonzal/vertical scrolling for free (<a href="https://stackoverflow.com/questions/2278625/android-imageview-scrolling-to-display-full-high-quality-image">here</a>). Or someone put the image in an imageview and gave the imageview an onTouchListener to handle scrolling (<a href="https://stackoverflow.com/questions/3058164/android-scrolling-an-imageview)">here</a>). The Problem with both ways is, that I either way I dont think you can put Buttons on top of the image, which is what I need to do.</p> <p>I would very appreciate if someone help me out.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload