读书人

为何有时要写android:有时又不写呢

发布时间: 2013-05-02 09:39:29 作者: rapoo

为什么有时要写android:,有时又不写呢?
<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/default_bg">

<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_alignParentBottom="true" android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_weight="1" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>

</TabHost>

为什么android:id="@android:id/tabhost"前加了android:,
但是android:background="@drawable/default_bg"前面又没有android:,
如果我写成android:background="@android:drawable/default_bg"还要报错,
这是怎么回事呢?
[解决办法]

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

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_heigh……


android:id="@android:id/tabhost" 这@android: 意思是引用android 系统自带的id

android:background="@drawable/default_bg" 这@drawable 意思是引用自己项目下 drawable 文件夹下的default_bg.xx 图片


LZ使用"@android:drawable/default_bg"是由于android系统 自带的资源图片没有以default_bg.xx 的图片

读书人网 >Android

热点推荐