Rafel Nadal
Rafel Nadal

Reputation: 21

How to add a scroll bar in PhoneGap

I have to add a scroll bar in PhoneGap. Please check my code below.

public class MyActivity extends DroidGap {
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        super.loadUrl("file:///android_asset/www/index.html");

        // Display vertical scrollbar and hide horizontal scrollBar
        super.appView.setVerticalScrollBarEnabled(true);
        super.appView.setHorizontalScrollBarEnabled(false);
        // set scrollbar style
        super.appView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    }
}

I get an error in this statement:

super.appView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

Upvotes: 1

Views: 1255

Answers (2)

josemmo
josemmo

Reputation: 7103

Perhaps you haven't added this line

import android.view.View;

before

public class MyActivity extends DroidGap {

Upvotes: 0

Furqi
Furqi

Reputation: 2403

Mobile WebKit (iOS and Android, etc) does not provide a native way to scroll content inside a fixed width/height element, but many libraries can help you with that issue.

I use the iScroll to scroll the content in my PhoneGap app. It's a very lightweight framework, only focuses on the scroll problem of mobile WebKit browser or WebViews, and it works perfect.

Here is a simple example .

Upvotes: 2

Related Questions