0

I added a progressbar in my custom webview, but when I scroll the view, it caused this error Error info:

This is my onScrollChanged method:

@Override
protected void onScrollChanged(int left, int top, int oldLeft, int oldTop) {
        LayoutParams layoutParams = (LayoutParams)  progressbar.getLayoutParams();
        layoutParams.leftMargin = left;
        layoutParams.topMargin = top;
        progressbar.setLayoutParams(layoutParams);
        super.onScrollChanged(left, top, oldLeft, oldTop);
    }

This is my imports:

    import com.fccs.library.R; 
import com.fccs.library.callback.SingleButtonCallBack; 
import com.fccs.library.notice.DialogUtils; 
import com.tencent.smtt.export.external.interfaces.JsResult; 
import com.tencent.smtt.sdk.WebSettings; 
import com.tencent.smtt.sdk.WebView; 
import android.annotation.SuppressLint; 
import android.content.Context; 
import android.content.Intent; 
import android.net.Uri; 
import android.util.AttributeSet; 
import android.view.KeyEvent; 
import android.view.View; 
import android.widget.ProgressBar;
Ethen
  • 11
  • 3

3 Answers3

0

Try replacing LayoutParams with FrameLayout.LayoutParams and check for yourself.

johnrao07
  • 6,690
  • 4
  • 32
  • 55
0

Change LayoutParams to AbsoluteLayout.LayoutParams

Keyur Lakhani
  • 4,321
  • 1
  • 24
  • 35
  • Yes, I changed the LayoutParams to AbsoluteLayout.LayoutParams, it worked. But, the AbsoluteLayout is deprecation – Ethen Jun 13 '16 at 06:25
  • @Ethen this might help you http://stackoverflow.com/questions/3294590/set-the-absolute-position-of-a-view – Keyur Lakhani Jun 13 '16 at 06:46
0

Every Layout provides its own LayoutParams class -- seems you're using the wrong one in the first line of the method. Check your import and fix it.

Ridcully
  • 23,362
  • 7
  • 71
  • 86