我正在制作一个聊天应用程序,但是当键盘出现时发生了什么,它隐藏了我的编辑文本,但当我移动我的布局时,我在其中编辑文本到layout_below到具有id“@ + id / Rl_ChatLayout”的上层相对布局“,它给了我一个IllegalStateException
我试图搞清楚但我找不到任何帮助 并研究了以下链接
Android Relative Layout circular dependencies error
这是我的xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff">
<RelativeLayout
android:id="@+id/TopLayout"
android:layout_width="match_parent"
android:layout_height="55dp">
<ImageButton
android:id="@+id/btn_back"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:background="@drawable/back_icon_2x"
android:textColor="#000000"
android:textSize="22sp" />
<LinearLayout
android:id="@+id/Image"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/btn_back">
<Button
android:id="@+id/recUserImg"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/image_circle_shape"
android:text=""
android:textColor="@color/white"
android:visibility="gone" />
<com.dd.sproutchat.customcontrols.MLRoundedImageView
android:id="@+id/userImg"
android:layout_width="50dp"
android:layout_height="50dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@+id/btn_Search"
android:layout_toRightOf="@+id/Image"
android:orientation="vertical">
<TextView
android:id="@+id/txtUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="start"
android:gravity="left"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/txtOnlineStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/black" />
</LinearLayout>
<ImageButton
android:id="@+id/btn_Menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:background="@drawable/menu_icon_2x"
android:visibility="gone" />
<ImageButton
android:id="@+id/btn_Search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:background="@drawable/search_icon_2x" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/Rl_line"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@+id/TopLayout"
android:background="@color/chat_border"></RelativeLayout>
<RelativeLayout
android:id="@+id/Rl_Options"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_below="@+id/Rl_line"
android:background="@color/chat_options_bg">
<ImageButton
android:id="@+id/btn_Home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:background="@drawable/home_btn_active_2x" />
<ImageButton
android:id="@+id/btn_SproutesList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/chat_btn_2x" />
<ImageButton
android:id="@+id/btn_Note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:background="@drawable/note_btn_2x" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/Rl_line2"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@+id/Rl_Options"
android:background="@color/chat_border"></RelativeLayout>
<RelativeLayout
android:id="@+id/Rl_ChatLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/Rl_MessageLayout"
android:layout_below="@+id/Rl_line2">
<!-- android:background="@drawable/chat_bg_2x" -->
<RelativeLayout
android:id="@+id/Btn_Chats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="4">
<RelativeLayout
android:id="@+id/count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<ImageButton
android:id="@+id/btn_Sortby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:background="@drawable/icon_sortby_sprout_2x" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/btn_AddSprout"
android:layout_toRightOf="@+id/btn_Sortby"
android:weightSum="2">
<Button
android:id="@+id/btn_AllSprouts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/btn_blue"
android:paddingBottom="3dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="3dp"
android:text="@string/AllSprouts"
android:textColor="@color/white" />
<Button
android:id="@+id/btn_AllFavorites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_weight="1"
android:background="@drawable/btn_blank"
android:paddingBottom="3dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="3dp"
android:text="@string/AllFavorites"
android:textColor="@color/grey_start" />
</LinearLayout>
<ImageButton
android:id="@+id/btn_AddSprout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/icon_add_sprout_2x" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/noteLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:visibility="gone">
<EditText
android:id="@+id/searchBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/imageButton4" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toLeftOf="@+id/imageButton5"
android:background="@drawable/sort" />
<ImageButton
android:id="@+id/imageButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:background="@drawable/add" />
</RelativeLayout>
</RelativeLayout>
<ListView
android:id="@+id/Lv_Chat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/Btn_Chats"
android:divider="@null"
android:dividerHeight="0dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:scrollbars="none"
android:stackFromBottom="true"
android:transcriptMode="normal"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/Rl_MessageLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@+id/Rl_ChatLayout"
android:background="@color/chat_screen_bottom">
<ImageButton
android:id="@+id/btn_Attachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:background="@drawable/attachment_icon_white_2x" />
<EditText
android:id="@+id/edt_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@+id/btn_Send"
android:layout_toRightOf="@+id/btn_Attachment"
android:background="@drawable/txt_field"
android:imeOptions="actionDone"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
/>
<ImageButton
android:id="@+id/btn_Send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:background="@drawable/icon_send_white_2x" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
这是我的日志猫
08-25 16:48:07.400 2725-2725/com.dd.sproutchat E/﹕ appName=com.dd.sproutchat, acAppName=/system/bin/surfaceflinger
08-25 16:48:07.400 2725-2725/com.dd.sproutchat E/﹕ 0
08-25 16:48:07.470 2725-2725/com.dd.sproutchat E/testing﹕ Profile pic boolean is true
08-25 16:48:07.471 2725-2725/com.dd.sproutchat E/testing﹕ Path already exist
08-25 16:48:07.471 2725-2725/com.dd.sproutchat E/testing﹕ Path is /storage/sdcard0/SproutChat/Profile Pictures
08-25 16:48:07.499 2725-2725/com.dd.sproutchat E/testing﹕ Profile pic boolean is true
08-25 16:48:07.499 2725-2725/com.dd.sproutchat E/testing﹕ Path already exist
08-25 16:48:07.499 2725-2725/com.dd.sproutchat E/testing﹕ Path is /storage/sdcard0/SproutChat/Profile Pictures
08-25 16:48:07.511 2725-2725/com.dd.sproutchat E/testing﹕ Profile pic boolean is true
08-25 16:48:07.511 2725-2725/com.dd.sproutchat E/testing﹕ Path already exist
08-25 16:48:07.511 2725-2725/com.dd.sproutchat E/testing﹕ Path is /storage/sdcard0/SproutChat/Profile Pictures
08-25 16:48:07.552 2725-2725/com.dd.sproutchat E/testing﹕ Profile pic boolean is true
08-25 16:48:07.552 2725-2725/com.dd.sproutchat E/testing﹕ Path already exist
08-25 16:48:07.552 2725-2725/com.dd.sproutchat E/testing﹕ Path is /storage/sdcard0/SproutChat/Profile Pictures
08-25 16:48:07.660 2725-2725/com.dd.sproutchat E/testing﹕ Profile pic boolean is true
08-25 16:48:07.660 2725-2725/com.dd.sproutchat E/testing﹕ Path already exist
08-25 16:48:07.660 2725-2725/com.dd.sproutchat E/testing﹕ Path is /storage/sdcard0/SproutChat/Profile Pictures
08-25 16:48:07.711 2725-2725/com.dd.sproutchat E/testing﹕ Profile pic boolean is true
08-25 16:48:07.711 2725-2725/com.dd.sproutchat E/testing﹕ Path already exist
08-25 16:48:07.711 2725-2725/com.dd.sproutchat E/testing﹕ Path is /storage/sdcard0/SproutChat/Profile Pictures
08-25 16:48:07.848 2725-2744/com.dd.sproutchat E/NativeCrypto﹕ ssl=0x6138a568 cert_verify_callback x509_store_ctx=0x60efb940 arg=0x0
08-25 16:48:07.848 2725-2744/com.dd.sproutchat E/NativeCrypto﹕ ssl=0x6138a568 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA
08-25 16:48:08.669 2725-2797/com.dd.sproutchat E/SignalR Status﹕ Connected Successfuly
08-25 16:48:09.003 2725-2744/com.dd.sproutchat E/NativeCrypto﹕ ssl=0x613880e0 cert_verify_callback x509_store_ctx=0x60efb940 arg=0x0
08-25 16:48:09.003 2725-2744/com.dd.sproutchat E/NativeCrypto﹕ ssl=0x613880e0 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA
08-25 16:48:09.631 2725-2725/com.dd.sproutchat E/SproutChat﹕ Size After Added::1
08-25 16:48:09.866 2725-2725/com.dd.sproutchat E/testing﹕ Profile pic boolean is true
08-25 16:48:09.867 2725-2725/com.dd.sproutchat E/testing﹕ Path already exist
08-25 16:48:09.867 2725-2725/com.dd.sproutchat E/testing﹕ Path is /storage/sdcard0/SproutChat/Profile Pictures
08-25 16:48:10.725 2725-2752/? E/NativeCrypto﹕ ssl=0x6318dfb8 cert_verify_callback x509_store_ctx=0x61385940 arg=0x0
08-25 16:48:10.726 2725-2752/? E/NativeCrypto﹕ ssl=0x6318dfb8 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA
08-25 16:48:10.836 2725-2725/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.dd.sproutchat, PID: 2725
java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1796)
at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:390)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:406)
at android.view.View.measure(View.java:16842)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:824)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:500)
at android.view.View.measure(View.java:16842)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
at android.view.View.measure(View.java:16842)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
at android.view.View.measure(View.java:16842)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2332)
at android.view.View.measure(View.java:16842)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2246)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1312)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1509)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1189)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6223)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5304)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
08-25 16:48:11.408 2725-2754/? E/NativeCrypto﹕ ssl=0x614a4c20 cert_verify_callback x509_store_ctx=0x615d8940 arg=0x0
08-25 16:48:11.408 2725-2754/? E/NativeCrypto﹕ ssl=0x614a4c20 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA
答案 0 :(得分:1)
从android:layout_above="@+id/Rl_MessageLayout"
移除android:id="@+id/Rl_ChatLayout"
它导致循环依赖“Rl_MessageLayout”。
这是因为'Rl_MessageLayout'表示'Rl_CharLayout'是android:layout_above
而Rl_CharLayout
表示Rl_MessageLayout
是android:layout_below
。由于这两者都是相互指代的,因此它成为循环参考。