TylerM
TylerM

Reputation: 151

Layout causing App to crash

so I have been trying to change the layout in a couple of my xmls but for some reason when I changed this one it crashes the app. The new layout looks like:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:background="@drawable/gradient_bg" >
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center" >

</RelativeLayout>
<!-- Footer aligned to bottom -->
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
 <Button
    android:id="@+id/ButtonOK"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" 
    android:layout_toLeftOf="@+id/ButtonAll"
    android:text="Go"
    style="@style/btnStyleBreakerBay"/>
    <Button
    android:id="@+id/ButtonAll"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" 
    android:text="See All"
    android:layout_toRightOf="@+id/ButtonOK"
    android:layout_toLeftOf="@+id/ButtonBack"
    style="@style/btnStyleBreakerBay"/>
    <Button
    android:id="@+id/ButtonBack"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" 
    android:text="Back"
    android:layout_toRightOf="@+id/ButtonAll"
    style="@style/btnStyleBreakerBay"/>
</RelativeLayout>
<ScrollView
android:id="@+id/scrollableContents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/footer"
android:layout_below="@id/header" >
    <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    >
<TextView android:id="@+id/typeEvent"
android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Type of Event:"
    android:visibility="gone"
    style="@style/black_text"/>

        <Spinner
    android:id="@+id/spinner_search_event"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:entries="@array/event_search_arrays"
    android:prompt="@string/event_prompt" 
    android:visibility="gone"     
    android:popupBackground="#31535c"/>

<!-- Name Label -->
<TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Type of Pavement:"
    style="@style/black_text"/>

        <Spinner
    android:id="@+id/spinner_search_pavement"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:entries="@array/pave_search_arrays"
    android:prompt="@string/pavement_prompt"
    android:popupBackground="#31535c" />

        <!-- Name Label -->
<TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Amount of Traffic:"
    style="@style/black_text"/>
        <Spinner
    android:id="@+id/spinner_search_traffic"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:entries="@array/traffic_search_arrays"
    android:prompt="@string/traffic_prompt" 
    android:popupBackground="#31535c"/>

        <!-- Name Label -->
<TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Type of Environment:"
    style="@style/black_text"/>
        <Spinner
    android:id="@+id/spinner_search_enviro"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:entries="@array/enviro_search_arrays"
    android:prompt="@string/enviro_prompt" 
    android:popupBackground="#31535c"/>

        <TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Max Miles away from you:"
    style="@style/black_text"/>
        <Spinner
    android:id="@+id/spinner_dist"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:entries="@array/dist_arrays"
    android:prompt="@string/dist_prompt" 
    android:popupBackground="#31535c"/>
        </LinearLayout>

</ScrollView>
</RelativeLayout>

Now the logcat says it is crashing because:

02-12 06:58:05.351: E/AndroidRuntime(2367): java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

And a couple more red lines but I think that is the main thing. Now I am guess that is has to do with how I have the buttons in @+id/footer so how could I fix this?

Thank you in advance,

Tyler

Upvotes: 1

Views: 1099

Answers (1)

Blackbelt
Blackbelt

Reputation: 157447

<Button
    android:id="@+id/ButtonOK"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" 
    android:layout_toLeftOf="@+id/ButtonAll"
    android:text="Go"
    style="@style/btnStyleBreakerBay"/>
    <Button
    android:id="@+id/ButtonAll"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1" 
    android:text="See All"
    android:layout_toRightOf="@+id/ButtonOK"
    android:layout_toLeftOf="@+id/ButtonBack"
    style="@style/btnStyleBreakerBay"/>

android:layout_toLeftOf="@+id/ButtonAll" and android:layout_toRightOf="@+id/ButtonOK" make a circular dependency.

Upvotes: 5

Related Questions