开发者

Android progress bar embedded in ui and not in dialog

开发者 https://www.devze.com 2023-01-26 11:41 出处:网络
Is there a way to embed the progress bar in the 开发者_如何学PythonUI with out an dialog. And not programmatically but with layout xml files.

Is there a way to embed the progress bar in the 开发者_如何学PythonUI 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"


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"/>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消