Frage

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?

War es hilfreich?

Lösung

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"

Andere Tipps

Reverse the order (and remove the + on 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" />

First place your ProgressBar somewhere in your relative layout correctly. You can do that by adding some other alignment properties with it's parent , i,e your relative layout. Then add the TextView by with properties relative to the ProgressBar.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top