【问题标题】:How to display a number inside a progress spinner如何在进度微调器中显示数字
【发布时间】:2013-12-23 07:42:31
【问题描述】:

我在菜单中显示了一个进度微调器。我想在微调器中显示一个数字,我该怎么做?以下是我正在做的一些代码 sn-ps 以使进度微调器工作:

public void onCreateOptionsMenu(...) {
    ...
    if (uploadCount > 0) {
        MenuItem updatingMenuItem = menu.findItem(R.id.photo_capture_action_updating);
        updatingMenuItem.setActionView(R.layout.action_progressbar);
        updatingMenuItem.expandActionView();
    } else {
        menu.removeItem(R.id.photo_capture_action_updating);
    }
}

下面是action_progressbar.xml

<?xml version="1.0" encoding="utf-8"?>
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/progressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">         
</ProgressBar>

谢谢,

【问题讨论】:

标签: java android


【解决方案1】:

您可以在此进度条中添加一个带有重心的文本视图,并将其包装在框架布局中。 xml-

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/progressBarLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

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

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="14" />
</FrameLayout>

希望这能解决您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-04
    • 2011-10-17
    • 2018-12-02
    • 1970-01-01
    • 2014-11-09
    • 2012-08-21
    相关资源
    最近更新 更多