title: HorizontalScrollView and image wrapping
body: <p>I've implemented a LinearLayout with a tall/narrow image on the left side (top to bottom) and a <code>HorizontalScrollView</code> on the right side for showing a long image.</p>
  
  <p>The problem is that I have not managed to handle the <code>HorizontalScrollView</code> properly. It does not show the left part of the image (I am unable to scroll in that direction), and it is possible to scroll far beyond the image borders on the other side...</p>
  
  <p>I have tried different types of wrapping for the image and the <code>HorizontalScrollView</code>, but the problem is always the same.</p>
  
  <p>Additionally, I have trouble with the left image; the wrapping does not work so there's white space on both sides of it.</p>
  
  <p>This is hard to explain, so I will instead give you some example code that presents the problem:</p>
  
  <p>XML file (I've made many versions of it but always having the same problem):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:adjustViewBounds="true"
      android:orientation="horizontal" &gt;
  
      &lt;LinearLayout 
          android:id="@+id/leftContainer"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:adjustViewBounds="true"
          android:orientation="horizontal" &gt;
          &lt;ImageView
              android:id="@+id/ivExampleBar"
              android:layout_width="wrap_content"
              android:layout_height="fill_parent"
              android:paddingLeft="0dp"
              android:paddingRight="0dp"
              android:contentDescription="Bar on the left side"
              android:src="@drawable/examplebar" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;HorizontalScrollView
          android:id="@+id/hscroll"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent" 
          android:layout_gravity="left"
          android:scrollbarFadeDuration="0"&gt;
  
          &lt;LinearLayout 
                  android:id="@+id/container"
                  android:layout_width="wrap_content"
                  android:layout_height="fill_parent"
                  android:layout_gravity="center_horizontal"
                  android:orientation="horizontal" &gt;
  
                  &lt;ImageView
                  android:id="@+id/ivExampleImg"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center"
                  android:contentDescription="Big scrollable image"
                  android:src="@drawable/exampleimg" 
              /&gt;
          &lt;/LinearLayout&gt;
      &lt;/HorizontalScrollView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Java file (I've tried ScrollTo in order to show also the left part of the image, but it works only on a specific resolution/phone...):</p>
  
  <pre><code>import android.app.Activity;
      import android.os.Bundle;
      import android.view.Window;
      import android.view.WindowManager;
      import android.widget.LinearLayout;
  
      public class TestActivity extends Activity {
  
          //private LinearLayout scrollContainer;
  
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
  
              // FULL SCREEN
              requestWindowFeature(Window.FEATURE_NO_TITLE);
              getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
              this.setContentView(R.layout.testlayout);
  
              //scrollContainer = (LinearLayout) findViewById(R.id.container);
              //scrollContainer.scrollTo(-195, 0);
  
  
          }
  
          @Override
          protected void onPause(){
              super.onPause();
              finish();
          }
      }
  </code></pre>
  
  <p>Do you have any help on these problems?</p>
  
  <ul>
  <li>make the HorizontalScrollView wrap my image so there's no white space around it</li>
  <li>make it possible to scroll all the way to the borders of the image</li>
  <li>avoid the white space around the left image</li>
  </ul>