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?

Xander
  • 5,487
  • 14
  • 49
  • 77

3 Answers3

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"

reVerse
  • 35,075
  • 22
  • 89
  • 84
  • One thing I forgot to tell (don't think it makes a difference though). I don't use it as a normal layout but I use it as a layout in a `AlertDialog`, so using the method `.setView()` – Xander Oct 17 '13 at 15:27
  • 1
    Actually this does change something. Now I've got the same problem as you ;) That's kinda strange, maybe you should use a LinearLayout for those two elements and center it. – reVerse Oct 17 '13 at 15:49
  • That dit the tric! Thank you!! – Xander Oct 17 '13 at 16:11
0

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" />
spacifici
  • 2,186
  • 2
  • 16
  • 28
0

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.

ayon
  • 2,180
  • 2
  • 17
  • 32