布局导致应用程序崩溃
问题描述:
所以我一直在尝试改变我的几个xml中的布局,但由于某种原因,当我改变这个崩溃的应用程序。新的布局看起来像:布局导致应用程序崩溃
<?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>
现在logcat的说,这是因为崩溃:
02-12 06:58:05.351: E/AndroidRuntime(2367): java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
和一对夫妇更红线,但我认为这是最主要的。现在我猜这与我在@ + id/footer中的按钮有关,所以我该如何解决这个问题?
谢谢你在前进,
泰勒
答
<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"
和android:layout_toRightOf="@+id/ButtonOK"
使循环依赖。
+0
谢谢,我摆脱了android:layout_toLeftOf =“@ + id/ButtonAll”和android:layout_toLeftOf = “@ + id/ButtonBack”,但现在ButtonOk不显示。 – TylerM
为了清楚你可以检查我的答案在这里http://*.com/a/11669528/1457952 – Shrikant