Java 在android中使用layout_toRightOf时应用程序崩溃

Java 在android中使用layout_toRightOf时应用程序崩溃,java,android,Java,Android,布局 <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_wid

布局

<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>

预期输出

android:layout\u alignParentRight=“true”
分配给
自动完成文本视图

 <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" />


您已经编写了
android:layout\u-toLeftOf=“@+id/item\u-autoComplete”
,然后在编写
android:layout\u-toRightOf=“@+id/textView1”
时,它创建循环依赖性显示您想要实现的设计数分钟后我会告诉您这是预期的结果…实际上我不希望文本字段不接触宽度尝试答案并让我知道它实际上没有崩溃。但是自动完成正在接触宽度的末端。您是否获得预期的结果?你所说的宽度末端是什么意思??屏幕的末端?我需要一些填充,这样它就不会接触到宽度的末端。请稍候,当您看到我的标签在左侧的“选择标签”中有一些边距时,我会给出一个示例。我需要在AutoMLegive
android:layout\u marginRight=“30dp”
 <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" />