布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<GridView
android:id="@+id/galleryImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="6"
android:scrollbars="horizontal" >
</GridView>
</LinearLayout>
代码:
myGV= (GridView) findViewById(R.id.galleryImage);
listImage = new profileAdapter(this, R.layout.layoutimage);
myGV.setAdapter(listImage);
我已按listImage
myGV.setNumColumns(listImage.getCount());
为什么Gridview的水平滚动条不起作用?
答案 0 :(得分:0)
您好请使用下面的xml代码我添加了HorizontalScrollView
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tool"
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:fillViewport="true" >
<GridView
android:id="@+id/galleryImage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="6">
</GridView>
</HorizontalScrollView>