0

I've got a ProgressBar, which is a spinner with a TextView above it, both inside the same relativelayout. These are the ProgressBar's and TextView's properties:

<TextView
    android:id="@+id/txtvStatusCircle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/progressCircle"
    android:layout_centerInParent="true"
    android:text="Preparing..."
    android:textSize="18dip" />

<ProgressBar
    android:id="@+id/progressCircle"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true" />

In the example Eclipse shows, it looks the way I want it, but when I run it, the TextView isn't shown at all. I'm breaking my mind over this! When I remove the above-part from the TextView, it is shown, but obviously not above the ProgressBar. Why isn't it working?

4

3 回答 3

1

Well your XML-Code works for me. Maybe the problem is something else? Aside from that I would also change the code to the following:

 <ProgressBar
    android:id="@+id/progressCircle"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true" />

<TextView
    android:id="@+id/txtvStatusCircle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@id/progressCircle"
    android:layout_centerHorizontal="true"
    android:text="Preparing..."
    android:textSize="18sp" />

What's the difference? Order changed thus no "+id" is needed. Changed textSize qualifier to sp (you should always use this) and finally removed the "centerInParent" from the TextView since this isn't needed when you say "above my element in the center"

于 2013-10-17T15:23:02.670 回答
0

颠倒顺序(并删除 layout_above 上的 +):

<ProgressBar
    android:id="@+id/progressCircle"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true" />
<TextView
    android:id="@+id/txtvStatusCircle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@id/progressCircle"
    android:layout_centerInParent="true"
    android:text="Preparing..."
    android:textSize="18dip" />
于 2013-10-17T14:53:11.273 回答
0

首先将 ProgressBar 正确放置在相对布局中的某个位置。您可以通过添加一些其他对齐属性来实现它的 parent ,即您的相对布局。然后通过相对于 ProgressBar 的属性添加 TextView。

于 2013-10-17T14:56:12.700 回答