Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: EditText with Progress bar?

I'm building a browser, and I have an address bar (as EditText) on top of the WebView. What I would like to do is to present the loading of the page graphically in the background of the EditText, much like in the iphone's browser. Is this possible?

Thanks


UPDATE

So far I have tried the ClipDrawable approach. What I did was to take the stock drawable android.R.drawable.editbox_background and create 2 versions - a white background and a blue one (to show the progress). Then I would create a LayerDrawable like so:

 barDrawable = addressBar.getBackground();

    Drawable progress = getResources().getDrawable(R.drawable.editbox_progress);
    cbarDrawable = new ClipDrawable(progress, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    cbarDrawable.setLevel(0);

    layerlist = new LayerDrawable(new Drawable[] { barDrawable, cbarDrawable });

    addressBar.setBackgroundDrawable(layerlist);

and then I would call setLevel as the loading progresses. The problem now is that there are weird issues such as: the white drawable is too big or it moves to the top.

What do you think?

like image 574
Alex1987 Avatar asked Feb 18 '11 19:02

Alex1987


People also ask

How to add progress bar android?

In android there is a class called ProgressDialog that allows you to create progress bar. In order to do this, you need to instantiate an object of this class. Its syntax is. ProgressDialog progress = new ProgressDialog(this);

How to show progress bar programmatically in android?

setVisibility(View. Visible) to show progress bar or you can use progressBar. setVisibility(View. Gone) to hide progress bar on activity.


1 Answers

Take a look at this link, which talks about overriding ProgressBar's onDraw() method and drawing text over it. That should get you started at least.

like image 126
Matt Avatar answered Oct 12 '22 15:10

Matt