可在一个Android XML中使用的最大名称空间数

时间:2014-04-29 18:32:55

标签: android xml namespaces

我需要知道我们可以在一个Android XML中使用多少个自定义命名空间

这里我使用两个自定义组件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:parallax="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<com.example.abc.components.ParallaxImageView
    android:id="@+id/background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    parallax:tiltSensitivity="2.5" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/transparent_white" >

    <TextView
        android:id="@+id/activity_registration_hi_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:text="@string/activity_registration_hi"
        android:textSize="@dimen/activity_title_text" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/activity_registration_hi_text"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:text="@string/activity_registration_welcome_text"
        android:textSize="@dimen/activity_large_text" />

    <Button
        android:id="@+id/activity_registration_sign_in_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:background="@drawable/signin_button_selector"
        android:text="@string/activity_registration_google_plus" />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/activity_registration_sign_in_button"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_marginTop="@dimen/activity_vertical_margin_reduced"
        android:background="@drawable/menu_left_devider" />

    <com.example.abc.components.FloatLabelEditText
        android:id="@+id/activity_change_password_old_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        app:hint="@string/activity_change_password_old_password_hint"
        app:textColor="@color/white"
        app:textColorHintFocused="@color/red"
        app:textColorHintUnFocused="@color/grey"
        app:textHintColor="@color/faded_white"
        app:textSize="@dimen/button_textSize" />
</RelativeLayout>

在FloatLabelEditText组件中,它给出了

  

未绑定的前缀错误

如果我从&#39; parallax&#39;更改命名空间到应用程序&#39;比ParallaxImageView给出错误。

我到处搜索了很多东西,但是canot解决了这个问题。 请有人告诉我。 我们可以在一个XML中使用多个自定义组件吗?

我可能错了,但请,需要帮助!

谢谢!

1 个答案:

答案 0 :(得分:0)

您在app:元素的属性中使用名称空间com.example.abc.components.FloatLabelEditText,在parallax元素上使用名称空间com.example.abc.components.ParallaxImageView,但只有一个名称空间是定义(除了android)。您需要将xmlns:app="*"添加到RelativeLayout元素,或将app:命名空间更改为parallax:,具体取决于属性的来源。

相关问题