Android: Can a static horizontal progress bar be embedded in a Textview?

人走茶凉 提交于 2020-01-15 06:56:32

问题


I don't think this is possible, but can a static (determinate) horizontal progress bar be embedded in a Textview?

Update1: I am trying to create a progress bar similar to that of the iPhone, but I also need text above it. Here is a picture: http://i.stack.imgur.com/aDFU9.png

Update2:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
<ProgressBar
    style="@android:style/Widget.ProgressBar.Horizontal"
    android:id="@+id/pbar1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:max="100"
    android:progress="45"
    android:maxHeight="5sp"
    android:layout_marginRight="5dp" />
</LinearLayout>

Here is the picture: http://i.stack.imgur.com/ypimG.png

Now my goal is to make this look like the previous picture.


回答1:


As TextView can't contain another view (there is no addChild() method) the answer is no.

Update: After looking at the picture, you should use a LinearLayout which contains a TextView and a ProgressBar.




回答2:


You can use

Prog = (ProgressBar) findViewById(R.id.pbar1);
Prog.setProgress((int) rounded);


来源:https://stackoverflow.com/questions/6117703/android-can-a-static-horizontal-progress-bar-be-embedded-in-a-textview

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