Android-在进度条的中心显示文本 [英] Android - displaying text in center of progress bar

查看:72
本文介绍了Android-在进度条的中心显示文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个水平进度条,并且效果很好.我想在它的中间显示一个textview或类似的东西,并显示该栏正在加载时的倒计时.请记住,它不是进度对话框,进度条位于活动中并显示倒数计时器.谁能帮帮我,什么是最好的方法,我该怎么做?

I have already made a horizontal progress bar and it works perfectly. I would like to display a textview or something similar right in the middle of it showing a countdown as the bar is loading. Keep in mind its not a progress dialog, progress bar resides inside an activity and shows a countdown timer. Can anyone help me out, whats the best way to do this and how can I accomplish this?

推荐答案

如果您的 ProgressBar TextView 位于 RelativeLayout 内,则可以给出 ProgressBar 一个id,然后使用它将 TextView ProgressBar 对齐.然后,它应该显示在 ProgressBar 的顶部.确保背景是透明的,以便您仍然可以看到 ProgressBar

If your ProgressBar and TextView are inside a RelativeLayout you can give the ProgressBar an id, and then align the TextView with the ProgressBar using that. It should then show on top of the ProgressBar. Make sure the background is transparent so that you can still see the ProgressBar

例如:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <ProgressBar
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        // other attributes
        android:id="@+id/PROGRESS_BAR"
    >
    <TextView
        android:background="#00000000" // transparent
        // other attributes
        android:layout_alignLeft="@id/PROGRESS_BAR"
        android:layout_alignTop="@id/PROGRESS_BAR"
        android:layout_alignRight="@id/PROGRESS_BAR"
        android:layout_alignBottom="@id/PROGRESS_BAR"
    >
</RelativeLayout>

这篇关于Android-在进度条的中心显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆