I am trying to programatically alter the height of a webview (used to display html) in a way that looks as though it is animating/expanding. My code works, but it is laggy. Sometimes it runs smoothly, other times it runs slowly, often the speed changes thruoghout the movement. My code is below. Does anyone have any good ways to fix this?
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);
}