无法弄清楚这个android错误

时间:2014-03-29 05:41:30

标签: android

<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="horizontal">
<EditText android:id="@+id/edit_message"
    android:layout_weight="1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:hint="@string/edit_message" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_send" />
</LinearLayout>

从这个(来自android教程)我得到一个错误,处理指令目标匹配&#34; [xX] [mM] [lL]&#34;是不允许的(这是在线开始

4 个答案:

答案 0 :(得分:3)

  1. <?xml version="1.0" encoding="utf-8"?>放在文件顶部
  2. 从LinearLayout
  3. 中删除xmlns:android="http://schemas.android.com/apk/res/android"

答案 1 :(得分:1)

放在#

行下面的顶部

<?xml version="1.0" encoding="utf-8"?>

从线#

下面的LinearLayout中删除
xmlns:android="http://schemas.android.com/apk/res/android"

有关详细信息,请参阅Stackoverflow Question

答案 2 :(得分:0)

我编辑了你的布局。这需要<?xml version="1.0" encoding="utf-8"?>来解决问题:

布局正确:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        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:orientation="horizontal" >

        <EditText
            android:id="@+id/edit_message"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="@string/edit_message" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_send" />
    </LinearLayout>

答案 3 :(得分:0)

<?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:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".MainActivity" >
 <LinearLayout 
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal">
<EditText android:id="@+id/edit_message"
  android:layout_weight="1"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:hint="@string/edit_message" />
<Button
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="@string/button_send" />
</LinearLayout>
</RelativeLayout>