Android - 在XML文件中声明海关组件的更优雅方式

时间:2012-05-29 02:12:26

标签: android xml custom-component hardcode

目前我有一个名为CustomizedGallery的类,它扩展了默认的Gallery。我将它包含在我的XML布局文件中:

      <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_marginLeft="80px"
    android:layout_marginTop="0px"
    android:layout_width="869px"
    android:layout_height="605px"
    android:background="#000000"
    android:orientation="horizontal" >

    <com.my.path.here.CustomizedGallery
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="864px"
        android:layout_height="600px"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:id="@+id/gallery" />
</RelativeLayout>

问题在于,每次我更改我的包名(com.my.path.here)时,我都必须手动编辑XML(因为它们不会像.java文件那样更新)。有没有办法可以在XML中包含我的custum gallery类,例如每次在使用我的自定义类的XML中都不需要编辑包名?

PS:你可能想知道为什么我经常改变包名。原因是因为我为同一个客户端构建了非常相似的应用程序,因此,我每次都需要更改软件包名称,以便稍微修改后的应用程序可以安装在同一个设备中。

提前谢谢!

0 个答案:

没有答案
相关问题