我在菜单中显示了一个进度微调器。我想在微调器中显示一个数字,我该怎么做呢?以下是我为使进度微调器正常工作所做的一些代码 fragment :
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>
谢谢你,
最佳答案
您可以将带有重心的 TextView 与此进度条一起添加,并将其包裹在框架布局中。 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>
希望这能解决您的问题。
关于java - 如何在进度微调器中显示数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20739079/