app:something...什么是应用:?
app:something...What is app:?
我正在使用 this famous ViewPagerIndicator library in my project. I wanted to add color on ViewPageIndicator
. I found a solution from here on Whosebug。
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
app:fillColor="#FF888888"
app:pageColor="#88FF0000"
app:strokeColor="#FF000000" />
但是这里有一件事我不明白:为什么写成app:
而不是android:
? app:
是什么意思?我没用过app:
?它的命名空间是什么?我用谷歌搜索但没有找到解决方案。
可能你只需要添加缺少的命名空间:
xmlns:app="http://schemas.android.com/apk/res-auto"
或者查看引用库的答案:
How can I set up custom namespaces in layout file in Android studio?
对于命名空间,添加:xmlns:app="http://schemas.android.com/apk/res-auto"
app 命名空间用于所有 'new' 属性。例如:如果我创建一个自定义视图,它有自己的属性(假设 RainbowView 有新属性 'numberOfColors'),那么我必须在 app 命名空间中使用该属性,因为它没有在 android 命名空间。因此,对所有自定义属性使用 app 命名空间。您可以自己定义属性,也可以添加添加的库的作者(在您的情况下为 CirclePageIndicator)。但大多数时候,当您开始输入 'strokeCo...' 并在自动完成列表中看到 'strokeColor' 时,命名空间将在您输入 select 时自动添加。
我正在使用 this famous ViewPagerIndicator library in my project. I wanted to add color on ViewPageIndicator
. I found a solution from here on Whosebug。
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
app:fillColor="#FF888888"
app:pageColor="#88FF0000"
app:strokeColor="#FF000000" />
但是这里有一件事我不明白:为什么写成app:
而不是android:
? app:
是什么意思?我没用过app:
?它的命名空间是什么?我用谷歌搜索但没有找到解决方案。
可能你只需要添加缺少的命名空间:
xmlns:app="http://schemas.android.com/apk/res-auto"
或者查看引用库的答案:
How can I set up custom namespaces in layout file in Android studio?
对于命名空间,添加:xmlns:app="http://schemas.android.com/apk/res-auto"
app 命名空间用于所有 'new' 属性。例如:如果我创建一个自定义视图,它有自己的属性(假设 RainbowView 有新属性 'numberOfColors'),那么我必须在 app 命名空间中使用该属性,因为它没有在 android 命名空间。因此,对所有自定义属性使用 app 命名空间。您可以自己定义属性,也可以添加添加的库的作者(在您的情况下为 CirclePageIndicator)。但大多数时候,当您开始输入 'strokeCo...' 并在自动完成列表中看到 'strokeColor' 时,命名空间将在您输入 select 时自动添加。