Mahmoud Abou-Eita
Mahmoud Abou-Eita

Reputation: 941

Drawing a ProgressBar on top of other views programmatically

I would like to create a Java method that's capable of drawing progress indicators on top of different views (ImageViews, Buttons, etc.. ). So that I can just call showProgess(View v) and hideProgress(View v) and the progress indicator will overlay only the passed view. What are the steps needed to achieve this?

Upvotes: 0

Views: 701

Answers (1)

piotrpo
piotrpo

Reputation: 12626

I'm not sure if its possible by just "writing a method"

If we have TextView and you want to show progress as overlay of it you can:

Create ViewTextViewWithProgress class:

ViewTextViewWithProgress extends RelativeLayout {

(...) }

Then use RelativeLayout layout and put into it ordinary TextView and you progress indicator.

Use your ViewTextViewWithProgress instead of ordinary TextView

A good place to start creating custom views: http://developer.android.com/guide/topics/ui/custom-components.html

Upvotes: 1

Related Questions