3

Does anybody tell me how do I make ScrollView if I want to use vertical and horizontal at the same time?

DonGru
  • 13,532
  • 8
  • 45
  • 55
Mustafa Güven
  • 15,526
  • 11
  • 63
  • 83

2 Answers2

2

look here, there is somebody who coded a solution for your problem. nothing trivial but a handy solution, i think.

Scrollview vertical and horizontal in android

Community
  • 1
  • 1
berlindev
  • 1,753
  • 14
  • 22
1

You can use both scroll view in this way it works for me

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 
<HorizontalScrollView 
android:orientation="horizontal"        
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 
<TableLayout 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<TableRow android:id="@+id/first"
android:layout_width="fill_parent" 
android:layout_height="fill_parent" >
<Button android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="back"></Button>

</TableRow>

 <TableRow android:id="@+id/second"
android:layout_width="fill_parent" 
android:layout_height="fill_parent" >

<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="Hole
No./Pic"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="Distance"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="Par"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="Stroke"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="Player-1"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="Player-2"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="Player-3"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="Player-4"></TextView>

</TableRow>

<TableRow android:id="@+id/third"
android:layout_width="fill_parent" 
android:layout_height="fill_parent" >
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="222yrds" android:textSize="24dp"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>

<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playra1"></EditText>
 <EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrb1"></EditText>
<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrc1"></EditText>
<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrd1"></EditText>     
</TableRow>

<TableRow android:id="@+id/third"
android:layout_width="fill_parent" 
android:layout_height="fill_parent" >
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="2"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>

<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playra2"></EditText>
 <EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrb2"></EditText>
<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrc2"></EditText>
<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrd2"></EditText>     
</TableRow>

<TableRow android:id="@+id/third"
android:layout_width="fill_parent" 
android:layout_height="fill_parent" >
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="2"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>
<TextView android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="1" android:textSize="24dp"></TextView>

<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playra3"></EditText>
 <EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrb3"></EditText>
<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrc3"></EditText>
<EditText android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text="       "
android:id="@+id/playrd3"></EditText>     
</TableRow>



</TableLayout> 

</HorizontalScrollView>

</ScrollView>
Avi Kumar
  • 4,403
  • 8
  • 36
  • 67
  • 1
    Works but scrolling is odd in this construct. One scrollview eats touches for other. so it doesn't scroll diagonally. – Pointer Null Sep 09 '11 at 12:20