[android-developers] Horizontal Vertical Scroll View

2010-12-22 Thread John Gaby
I need to be able to have a view which scrolls both horizontally and
vertically (e.g. like a browser view).  I have seen several posts
where people have put a horizontal scroll view inside a vertical
scroll view.  I have tried to do that, but I only get vertical
scrolling.  The following is the code I am using:

public class ScrollTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

ScrollView sv = new ScrollView(this);
HorizontalScrollView hsv = new HorizontalScrollView(this);
ImageView iv = new ImageView(this);

int id = getResources().getIdentifier(getPackageName() +
:drawable/level1, null, null);

if (id != 0)
{
iv.setImageResource(id);
}

hsv.addView(iv, new ViewGroup.LayoutParams(1000, 1000));
sv.addView(hsv, new ViewGroup.LayoutParams(1000, 1000));

setContentView(sv);
}
}

Note that if I create just a HorzontalScrollView or just a ScrollView,
they both work independently.  When I combine them, I only get a
vertical scroll.  Does anyone have an Idea about what is wrong here?

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Horizontal Vertical Scroll View

2010-12-22 Thread Dianne Hackborn
You can't put a horizontal scroll view in a vertical scroll view.  You
probably just want to take the implementation of scroll view and modify it
to suit your needs.

On Wed, Dec 22, 2010 at 3:21 PM, John Gaby jg...@gabysoft.com wrote:

 I need to be able to have a view which scrolls both horizontally and
 vertically (e.g. like a browser view).  I have seen several posts
 where people have put a horizontal scroll view inside a vertical
 scroll view.  I have tried to do that, but I only get vertical
 scrolling.  The following is the code I am using:

 public class ScrollTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

ScrollView sv = new ScrollView(this);
HorizontalScrollView hsv = new HorizontalScrollView(this);
ImageView iv = new ImageView(this);

int id = getResources().getIdentifier(getPackageName() +
 :drawable/level1, null, null);

if (id != 0)
{
iv.setImageResource(id);
}

hsv.addView(iv, new ViewGroup.LayoutParams(1000, 1000));
sv.addView(hsv, new ViewGroup.LayoutParams(1000, 1000));

setContentView(sv);
}
 }

 Note that if I create just a HorzontalScrollView or just a ScrollView,
 they both work independently.  When I combine them, I only get a
 vertical scroll.  Does anyone have an Idea about what is wrong here?

 Thanks

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en