Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android progress bar embedded in ui and not in dialog

Is there a way to embed the progress bar in the UI with out an dialog. And not programmatically but with layout xml files. I am guessing it has to be some sort of animation or a "drawable"

like image 929
user498584 Avatar asked Nov 22 '10 04:11

user498584


2 Answers

You can use the ProgressBar widget:

<ProgressBar
    android:id="@+id/a_progressbar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

You can customize it with your own image if you want. You just have to create a styles file (res/styles.xml) like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AProgressBar">
        <item name="android:indeterminateDrawable">@drawable/progress_small</item>
        <item name="android:minWidth">20dip</item>
        <item name="android:maxWidth">20dip</item>
        <item name="android:minHeight">20dip</item>
        <item name="android:maxHeight">20dip</item>
    </style>
</resources>

@drawable/progress_small makes reference to an image file called progress_small.png. Then, just modify your progress bar this way:

<ProgressBar
    android:id="@+id/a_progressbar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="@style/AProgressBar"/>
like image 157
Cristian Avatar answered Sep 21 '22 20:09

Cristian


Yes you can use the Widget "ProgressBar" in your xml: http://developer.android.com/reference/android/widget/ProgressBar.html

Visual indicator of progress in some operation. Displays a bar to the user representing how far the operation has progressed; the application can change the amount of progress (modifying the length of the bar) as it moves forward. There is also a secondary progress displayable on a progress bar which is useful for displaying intermediate progress, such as the buffer level during a streaming playback progress bar.

A progress bar can also be made indeterminate. In indeterminate mode, the progress bar shows a cyclic animation. This mode is used by applications when the length of the task is unknown.

like image 30
Patrick Boos Avatar answered Sep 20 '22 20:09

Patrick Boos