当前位置: 动力学知识库 > 问答 > 编程问答 >

android.widget.AbsoluteLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: