如何在android中分配资源ID?我使用aapt dump resources
浏览正常的应用程序资源:
Package Groups (1)
Package Group 0 id=127 packageCount=1 name=com.android.picker
Package 0 id=127 name=com.android.picker typeCount=5
type 0 configCount=0 entryCount=0
type 1 configCount=1 entryCount=7
spec resource 0x7f020000 com.android.picker:drawable/btn_normal: flags=0x00000000
spec resource 0x7f020001 com.android.picker:drawable/icon: flags=0x00000000
spec resource 0x7f020002 com.android.picker:drawable/icon1: flags=0x00000000
.......
从上面的消息中,我发现资源id以127(0x7f)开头。我浏览另一个应用程序资源:
Package Groups (1)
Package Group 0 id=2 packageCount=1 name=com.android.pinkskin
Package 0 id=2 name=com.android.pinkskin typeCount=6
type 0 configCount=0 entryCount=0
type 1 configCount=1 entryCount=7
spec resource 0x02020000 com.android.pinkskin:drawable/btn_default: flags=0x00000000
spec resource 0x02020001 com.android.pinkskin:drawable/btn_default_normal: flags=0x00000000
spec resource 0x02020002 com.android.pinkskin:drawable/btn_default_normal_disable: flags=0x00000000
spec resource 0x02020003 com.android.pinkskin:drawable/btn_default_normal_disable_focused: flags=0x00000000
.........
两个应用程序之间的区别在于它们的make文件: com.android.picker make文件是:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := Picker
include $(BUILD_PACKAGE)
和com.android.pinkskin应用程序的make文件是:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := PiknSkin
LOCAL_AAPT_FLAGS := -x
LOCAL_EXPORT_PACKAGE_RESOURCES := true
include $(BUILD_PACKAGE)
我找到了Android resource id always have a package identifier, so their value cannot be 0. – Romain Guy。谁可以解释一下?