Android 项目生成时接收错误-“;分析XML时出错:未绑定前缀“0”;
我是Android开发新手,正在尝试创建一个示例应用程序。有谁能告诉我下面的布局(activity_sample.xml)有什么问题吗-Android 项目生成时接收错误-“;分析XML时出错:未绑定前缀“0”;,android,android-layout,Android,Android Layout,我是Android开发新手,正在尝试创建一个示例应用程序。有谁能告诉我下面的布局(activity_sample.xml)有什么问题吗- 您尚未在XML中声明工具前缀。尝试使用: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_pa
您尚未在XML中声明工具前缀。尝试使用:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/app_name"
tools:context=".SampleActivity" />
</LinearLayout>
layout\u center horizontal
和layout\u center vertical
是RelativeLayout的成员,它们不会为线性布局做任何事情。(如果要同时使用这两种方法,请使用布局\u centerInParent
)@Sam-+1。但是TextView的属性如何依赖于其父容器?您可以在线性布局的每个子项中使用layout\u gravity
,也可以在线性布局本身的所有子项中使用gravity
。
error: Error parsing XML: unbound prefix activity_sample.xml /Sample/res/layout line 4 Android AAPT Problem
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/app_name"
tools:context=".SampleActivity" />
</LinearLayout>