来自Rick Rogers的O'Reilly着作"Android应用程序开发",John Lombardo,Zigurd Mednieks和Blake Meike,第23页:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
Run Code Online (Sandbox Code Playgroud)
从第44页开始:
<application android:icon="@drawable/icon2">
Run Code Online (Sandbox Code Playgroud)
@上述每个片段的含义是什么?
在这种情况下:
android:layout_width="fill_parent"
Run Code Online (Sandbox Code Playgroud)
属性的值android:layout_width,直接在引号内指定fill_parent.在另一种情况下:
android:text="@string/hello"
Run Code Online (Sandbox Code Playgroud)
属性的值是在android:text="@string/hello"别处指定的.这由@字符串的开头表示.在这个例子中它是 @string/hello.该值位于资源中.
来自Android Developers网站的AndroidManifest.xml文件中的"资源值"部分.从allclaws链接中找到答案.
资源值以下列格式表示,
@ [包:]类型:名称
如果资源与应用程序位于同一个包中,则可以省略包名称,type是一种资源 - 例如"string"或"drawable" - 而name是标识特定资源的名称.