ScrollView not scrolling after adding content dynamically
Here is my layout :
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/button_scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fillViewport="true">
<LinearLayout
android:id="@+id/buttons"
android:orientation="horizontal"
android:layout_width="fill_parent开发者_如何学运维"
android:layout_height="wrap_content"
android:gravity="center_horizontal"/>
</ScrollView>
</LinearLayout>
In my code, I am adding buttons into the horizontal LinearLayout id/buttons. Everything goes well except that after I add enough of them, it never scrolls.
I tried :
- call invalidate on the ScrollView
- Change the layout_width for the LinearLayout to wrap_content
Try using HorizontalScrollView! ScrollView layout only scrolls vertically, as i found out a few weeks ago trying the same thing!
精彩评论