2011-05-24 47 views
2

我不认为这是可能的,但是可以在Textview中嵌入一个静态(确定的)水平进度条吗?Android:Textview中可以嵌入静态水平进度条吗?

Update1:​​我正在尝试创建一个类似于iPhone的进度条,但我也需要它上面的文本。 这里有一个画面: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> 

这里是图片:http://i.stack.imgur.com/ypimG.png

现在我的目标是让这个看起来像一张图片。

+0

像@WarrenFaith说,答案基本上是没有的,但如果你解释你所要完成什么,我相信我们可以拿出一大堆的方法可以做到它。 – slund 2011-05-24 22:48:38

+0

@slund:张贴我想要完成的内容。 – AG1 2011-05-24 23:20:34

+0

您应该看看LinearLayout的重力属性。还要检查边距,填充,文本大小和背景。有了这个,你应该可以做到与图片几乎相同的布局。但不要忘记:它不是iPhone!所以你应该得到Android的外观和感觉。就我个人而言,我讨厌在我的android上看起来像是iPhone应用程序的应用程序... – WarrenFaith 2011-05-25 09:36:20

回答

2

由于TextView不能包含另一个视图(没有addChild()方法)答案是否定的。

更新:查看图片后,应该使用包含TextView和ProgressBar的LinearLayout。

+0

在什么类型的视图应放置ProgressBar? – AG1 2011-05-24 23:25:34

+0

@ AG1:更新了我的答案。 – WarrenFaith 2011-05-24 23:43:09

0

您可以使用

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