tobiasrohloff / NestedScrollWebView

An Android WebView that implements NestedScrollingChild, in order to use it with CoordinatorLayout and AppBarLayout.
Other
334 stars 81 forks source link

No (visible) scroll bar #3

Closed kabukky closed 8 years ago

kabukky commented 8 years ago

Hi, thanks for your project. I just replaced my old vanilla WebView with NestedScrollWebView and while everything else seems fine, there is one difference: NestedScrollWebView has no scroll bar on the right side. Are you seeing this on your end too?

Thanks Kai

tobiasrohloff commented 8 years ago

Hi,

I don't think this is related to NestedScrollWebView, since it just extends the regular Android WebView.

Try setting

webView.setScrollbarFadingEnabled(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);

on your WebView.

kabukky commented 8 years ago

I found a fix. It seems to be a problem with passing down the constructor arguments to NestedScrollWebView(Context context, AttributeSet attrs, int defStyleAttr). Calling super instead brings back the scroll bar.

You are doing this:

    public NestedScrollWebView(Context context) {
        this(context, null);
    }

    public NestedScrollWebView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public NestedScrollWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mChildHelper = new NestedScrollingChildHelper(this);
        setNestedScrollingEnabled(true);
    }

Here's how I fixed it:

    public NestedScrollWebView(Context context) {
        super(context);

        mChildHelper = new NestedScrollingChildHelper(this);
        setNestedScrollingEnabled(true);
    }

    public NestedScrollWebView(Context context, AttributeSet attrs) {
        super(context, attrs);

        mChildHelper = new NestedScrollingChildHelper(this);
        setNestedScrollingEnabled(true);
    }

    public NestedScrollWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mChildHelper = new NestedScrollingChildHelper(this);
        setNestedScrollingEnabled(true);
    }
tobiasrohloff commented 8 years ago

Thanks for providing a fix.