Android布局文件xml
16lz
2021-01-24
http://blog.csdn.net/pipisorry/article/details/24833325
怎么在android的XML文件中添加注释
android的XML文件注释一般采用<!--注释内容-->的方式进行
在XML中,形如 <Button /> 的表示方式,其中“/>”的含义表示这个XML中没有内文,他是一个最小组成单元,也就是说他的中间不能包含其他任何< >的代码,所以在<Button />中间注释会出现错误
注意看到,在注释的前面有一个“>”符号,这就是我们能够在他中间进行注释的原因,他的完整结构是
<RelativeLayout ></RelativeLayout>
这就不是最小组成单元的表示方式了
- <?xmlversion="1.0"encoding="utf-8"?>
- <RelativeLayoutandroid:id="@+id/right"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <!--在这里注释是没有问题的-->
- <TextViewandroid:id="@+id/right_view1"
- android:background="@drawable/yellow"android:layout_width="fill_parent"
- android:layout_height="wrap_content"android:text="第二组第一项"/>
- <!--在这里注释也是没有问题的-->
- <TextViewandroid:id="@+id/right_view2"
- android:background="@drawable/blue"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/right_view1"android:text="第二组第二项"/>
- </RelativeLayout>
即只能在组件布局代码后,或者在组件的前面添加注释。如下所示:
<RelativeLayoutandroid:id="@+id/item_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!---->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!---->
</LinearLayout>
</RelativeLayout>
皮皮blog
相关错误解决
Hardcoded string "???", should use @string resource
在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string "下一步", should use @string resourcecopy
- <Button
- android:id="@+id/button1"
- android:layout_width="118dp"
- android:layout_height="wrap_content"
- android:text="下一步"/>"
- <?xmlversion="1.0"encoding="utf-8"?>
- <resources>
- <stringname="message">下一步</string>
- </resources>
<span class="atn">android:text</span><span class="pun">=</span><span class="atv">"@string/message"</span>就行了。这样做可以做到一改全改,在支持多语言时也是很有用的。另外,颜色的设置也最好在color.xm中类似设置。
from:http://blog.csdn.net/pipisorry/article/details/24833325
ref:
更多相关文章
- Android(安卓)硬解码 MediaCodec 遇到的(部分手机绿屏)API21
- Android(安卓)-- service两种启动方式startService与bindService
- Android(安卓)适配之FileProvider的使用
- Android(安卓)Studio的NDK的两种编译方式ndk-build和CMake
- 【Android】使用SharedPreferences判断应用程序是否首次启动
- 实例详解Android文件存储数据方式
- android进行异步更新UI的四种方式(转载)
- Android解惑 - 为什么要用Fragment.setArguments(Bundle bundle)
- ffmpeg 怎么用