我正在尝试以一种看起来像是动画/扩展的方式以编程方式更改 webview(用于显示 html)的高度。我的代码工作,但它是滞后的。有时它运行平稳,有时它运行缓慢,通常速度会随着运动而变化。我的代码如下。有没有人有什么好的方法来解决这个问题?
class ViewDropDownASynch extends AsyncTask<String,Void,String>{
WebView wv;
int height = 0;
LinearLayout.LayoutParams params;
int stop;
int step;
public ViewDropDownASynch(WebView v, int a, int o, int e){
wv = v;
params = new LinearLayout.LayoutParams(wv.getLayoutParams());
height = a;
stop = o;
step = e;
textAnimateExecute = true;
}
public String doInBackground(String... para){
for(int i = height; i != stop+step; i+=step){
params.height = i;
SystemClock.sleep(4);
this.publishProgress();
}
return "";
}
protected void onPostExecute(String result){
textAnimateExecute = false;
}
protected void onProgressUpdate(Void...values){
wv.setLayoutParams(params);
}