rafaelasguerra
rafaelasguerra

Reputation: 2555

How can I add a vertical scrollbar to a gridview?

The problem was that I had a setEnabled in my code. Sorry. I already fix this

I want that my gridview with height = 70dp is scrollable vertically.

<GridView
    android:id="@+id/list_label"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:numColumns="2"
    />

Anybody can help me with this?

Upvotes: 3

Views: 20120

Answers (5)

Suman Shrestha
Suman Shrestha

Reputation: 3

This will work. Use this on .java file.

gridView = (GridView)findViewById(R.id.list_label); 
ViewCompat.setNestedScrollingEnabled(gridView,true);

Upvotes: 0

Amal Mabrouk
Amal Mabrouk

Reputation: 11

gridView = (GridView)findViewById(R.id.rvProduit1); 
ViewCompat.setNestedScrollingEnabled(gridView,true);

Upvotes: 1

Shailendra Madda
Shailendra Madda

Reputation: 21551

Try to use:

android:scrollbars="vertical"

For vertical scrollbar

Upvotes: 2

Faraz Baig
Faraz Baig

Reputation: 64

<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView1"
android:numColumns="2"
android:gravity="center"
android:columnWidth="70dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:scrollbars="horizontal"
android:layout_height="fill_parent" >
</GridView>

Upvotes: 5

Arjun
Arjun

Reputation: 44

Add

 android:scrollbars="horizontal"

Upvotes: 0

Related Questions