问题描述:

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

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;

网友答案:

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

网友答案:

Change LayoutParams to AbsoluteLayout.LayoutParams

网友答案:

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.

相关阅读:
Top