i needed help in adding android:layout_below and after adding succesfully now my apps crashes when ever i start to see the result i hope you help me this is my code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/secondLine"
android:layout_alignParentLeft="true"
android:gravity="center_vertical"
android:text="@string/state1"
android:textSize="16sp" />
<TextView
android:id="@+id/secondLine"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_below="@id/textView1"
android:ellipsize="marquee"
android:singleLine="true"
android:text="@string/sayer1"
android:textSize="12sp" />
</RelativeLayout>
and this my logcat
12-18 13:57:18.581: D/AndroidRuntime(2237): Shutting down VM
12-18 13:57:18.581: W/dalvikvm(2237): threadid=1: thread exiting with uncaught exception (group=0x411e62a0)
12-18 13:57:18.581: E/AndroidRuntime(2237): FATAL EXCEPTION: main
12-18 13:57:18.581: E/AndroidRuntime(2237): java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1321)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:316)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:337)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.View.measure(View.java:15481)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.View.measure(View.java:15481)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.View.measure(View.java:15481)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
12-18 13:57:18.581: E/AndroidRuntime(2237): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2361)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.View.measure(View.java:15481)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1999)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1238)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1413)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1131)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4611)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.Choreographer.doFrame(Choreographer.java:525)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.os.Handler.handleCallback(Handler.java:615)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.os.Handler.dispatchMessage(Handler.java:92)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.os.Looper.loop(Looper.java:137)
12-18 13:57:18.581: E/AndroidRuntime(2237): at android.app.ActivityThread.main(ActivityThread.java:4898)
12-18 13:57:18.581: E/AndroidRuntime(2237): at java.lang.reflect.Method.invokeNative(Native Method)
12-18 13:57:18.581: E/AndroidRuntime(2237): at java.lang.reflect.Method.invoke(Method.java:511)
12-18 13:57:18.581: E/AndroidRuntime(2237): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
12-18 13:57:18.581: E/AndroidRuntime(2237): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
12-18 13:57:18.581: E/AndroidRuntime(2237): at dalvik.system.NativeStart.main(Native Method)
You are assigning a
textView1
toandroid:layout_alignBottom="@+id/secondLine"
and to second TextView you are assigningsecondLine
toandroid:layout_below="@id/textView1"
it mean you are assigning one textview to another and that second to first one.
this is creting Circular dependencies.
You can not assing
TextView1 <--> TextView2
connections. you can assign only single side.remove either of the line.
or
Both TextViews are pointing to each of them like android:layout_alignBottom="@+id/secondLine" and android:layout_below="@id/textView1" so it forms like circular loop, hence you are getting the error. Remove this android:layout_alignBottom="@+id/secondLine" from first textview
for textview1
and
for textView2
causes
Remove one of them and it should work
Place second
TextView
with idsecondLine
relative toTextView
with idtextview1
. You have Circular dependencies which is not possible and hence the error.You need to place once view relative to another.