I want to set the width and height of a progress circle to the height of the item next to it, a button. In the end I want to have a circle with equal height and width, that occupies the total height of the search button - if there's an easier way to do that, please tell me.
I guess this cannot be done using simple XML, so I'm trying to use LayoutParams for this, in the OnCreate() function of my activity:
LayoutParams lpe = search.getLayoutParams();
LayoutParams lpp = searchProgress.getLayoutParams();
lpp.width = lpe.height;
lpp.height = lpp.width;
Toast.makeText(getBaseContext(),"Width: "+lpp.width,Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(),"Height: "+lpp.height,Toast.LENGTH_LONG).show();
searchProgress.setLayoutParams(lpp);
This doesn't work for the width, however it does work for the height. I added the toasts to see some debugging info. Both lpp.width and lpp.height are -2. What does that mean? Here's the XML:
<Button
    android:id="@+id/searchButton"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/searchProgress"
    android:layout_alignTop="@+id/searchProgress"
    android:layout_toLeftOf="@+id/searchProgress"
    android:text="@string/searchButton" />
<ProgressBar
    android:id="@+id/searchProgress"
    style="?android:attr/progressBarStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/searchBar"
    android:layout_alignRight="@+id/searchResult"
    android:layout_alignTop="@+id/searchBar"
    android:indeterminate="true"
    android:indeterminateBehavior="repeat" />
According to this -2 means wrap_content. But I don't want to have the height as it is in the XML, I can see that myself. I want the height calculated by the device. 
How can I get this to work?
 
     
    