Android progress bar embedded in ui and not in dialog

情到浓时终转凉″ 提交于 2019-12-10 13:26:17

问题


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"


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/4242295/android-progress-bar-embedded-in-ui-and-not-in-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!