布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e6e6e6">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/headerbar"
android:padding="10dip" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"
android:src="@drawable/logo" />
<TextView
android:id="@+id/textViewtest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignParentRight="true"
android:layout_marginRight="18dp"
android:text="@string/appsetting"
android:background="@drawable/pinkbuttonbackground"
android:layout_centerVertical="true"
android:padding="5dp"
android:textAppearance="@dimen/textfontsize" />
</RelativeLayout>
<Button
android:id="@+id/item_buttonId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/okButton"
android:textColor="#ffffff"
android:background="#be0054"
android:textStyle="bold" />
<AutoCompleteTextView
android:id="@+id/item_autoComplete"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:textCursorDrawable="@null"
android:background="@drawable/background_textfield"
android:singleLine="true"
android:paddingLeft="2dp"
android:textColor="#000000" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="38dp"
android:layout_marginTop="84dp"
android:layout_toLeftOf="@+id/item_autoComplete"
android:text="@string/chooseStation"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#d70261" />
</RelativeLayout>
![] [1]
![在此输入图片说明] [2]
我写的应用程序崩溃l android:layout_toRightOf =&#34; @ + id / textView1&#34; 我的textView1是textview名称&#34;选择station&#34;实际上在textview下方有自动完成字段。我需要在右边移动..当我使用这个 android:layout_toRightOf =&#34; @ + id / textView1&#34; 它崩溃.. 此处为日志
11-01 13:20:56.556: E/AndroidRuntime(2112): FATAL EXCEPTION: main
11-01 13:20:56.556: E/AndroidRuntime(2112): java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1286)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:294)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:314)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.View.measure(View.java:12603)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4677)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.View.measure(View.java:12603)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4677)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.View.measure(View.java:12603)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4677)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
11-01 13:20:56.556: E/AndroidRuntime(2112): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2072)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.View.measure(View.java:12603)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1044)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2418)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.os.Handler.dispatchMessage(Handler.java:99)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.os.Looper.loop(Looper.java:137)
11-01 13:20:56.556: E/AndroidRuntime(2112): at android.app.ActivityThread.main(ActivityThread.java:4340)
11-01 13:20:56.556: E/AndroidRuntime(2112): at java.lang.reflect.Method.invokeNative(Native Method)
11-01 13:20:56.556: E/AndroidRuntime(2112): at java.lang.reflect.Method.invoke(Method.java:511)
11-01 13:20:56.556: E/AndroidRuntime(2112): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-01 13:20:56.556: E/AndroidRuntime(2112): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-01 13:20:56.556: E/AndroidRuntime(2112): at dalvik.system.NativeStart.main(Native Method)
预期输出
答案 0 :(得分:1)
将android:layout_alignParentRight="true"
分配给AutoCompleteTextView
:
<AutoCompleteTextView
android:id="@+id/item_autoComplete"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:textCursorDrawable="@null"
android:background="@drawable/background_textfield"
android:singleLine="true"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true"
android:paddingLeft="2dp"
android:textColor="#000000" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="38dp"
android:layout_marginTop="84dp"
android:text="chooseStation"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#d70261" />