Reputation: 3273
Why my scroll view doesn't scroll?
Here are my xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_marginTop="20dip"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b1"
android:onClick="b1" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b2"
android:onClick="b2" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b3"
android:onClick="b3" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b4"
android:onClick="b4" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/b5"
android:onClick="b5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b6"
android:onClick="b6" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b7"
android:onClick="b7" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b8"
android:onClick="b8" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b9"
android:onClick="b9" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/b10"
android:onClick="b10" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b11"
android:onClick="b11" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b12"
android:onClick="b12" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b13"
android:onClick="b13" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b14"
android:onClick="b14" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/b15"
android:onClick="b15" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b16"
android:onClick="b16" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b17"
android:onClick="b17" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b18"
android:onClick="b18" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b19"
android:onClick="b19" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/b20"
android:onClick="b20" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip" >
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b21"
android:onClick="b21" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b22"
android:onClick="b22" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b23"
android:onClick="b23" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_weight="1"
android:background="@drawable/b24"
android:onClick="b24" />
<Button
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/b25"
android:onClick="b25" />
</LinearLayout>
</LinearLayout>
</ScrollView>
Any idea?
Upvotes: 0
Views: 364
Reputation: 2576
I'm not sure it works, but you may also try to add android:scrollbars="vertical" attribute to your LinearLayout
Upvotes: 0
Reputation: 2263
ScrollView cannot hold more than 1 child.. it needs 1 single child which hosts all other view.. Hope this help you
<ScrollView>
<LinearLayout
android:id="@+id/child">
<ImageView/>
</LinearLayout>
</ScrollView>
Upvotes: 3
Reputation: 6960
Everything works fine, you just have not enough buttons to enable scrolling(you don't need it).
For see how scrolling works, use less screen size, or add more Linearlayouts
with buttons
.
Upvotes: 1