Android 将自定义视图集成到我的应用程序中

Android 将自定义视图集成到我的应用程序中,android,xml,android-layout,android-custom-view,Android,Xml,Android Layout,Android Custom View,我正在构建我的应用程序,我需要在布局中为其设置搜索弧。我使用了开源github项目中的seekarc视图。我几乎已经完成了将其合并到我的应用程序中,但是当我在布局xml中定义seekarc代码时,我陷入了困境。我的xml代码如下所示: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android

我正在构建我的应用程序,我需要在布局中为其设置搜索弧。我使用了开源github项目中的seekarc视图。我几乎已经完成了将其合并到我的应用程序中,但是当我在布局xml中定义seekarc代码时,我陷入了困境。我的xml代码如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.test.MainActivity" >

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Switch On"
    android:id = "@+id/onbtn"
    android:layout_centerHorizontal="true" />

 <com.triggertrap.seekarc.SeekArc
    android:id="@+id/seekArc"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:padding="30dp"
    seekarc:rotation="180"
    seekarc:startAngle="30"
    seekarc:sweepAngle="300"
    seekarc:touchInside="true" />


</RelativeLayout>
在该xml中的seekarc视图上。请让我知道我应该做些什么进一步的修改,这样就不会有错误了。我已经将所有相关的属性XML和Drawable集成到适当的文件夹中

试试这个

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:seekarc="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.test.MainActivity" >

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Switch On"
    android:id = "@+id/onbtn"
    android:layout_centerHorizontal="true" />

 <com.triggertrap.seekarc.SeekArc
    android:id="@+id/seekArc"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:padding="30dp"
    seekarc:rotation="180"
    seekarc:startAngle="30"
    seekarc:sweepAngle="300"
    seekarc:touchInside="true" />


</RelativeLayout>


您缺少定义
xmlns:seekarc=”http://schemas.android.com/apk/res-auto“

非常感谢您。现在这个错误已经消失了。请让我知道这句话的目的和意义,以便我能理解。请把这句话通读一遍
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:seekarc="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.test.MainActivity" >

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Switch On"
    android:id = "@+id/onbtn"
    android:layout_centerHorizontal="true" />

 <com.triggertrap.seekarc.SeekArc
    android:id="@+id/seekArc"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:padding="30dp"
    seekarc:rotation="180"
    seekarc:startAngle="30"
    seekarc:sweepAngle="300"
    seekarc:touchInside="true" />


</RelativeLayout>