简体   繁体   中英

How to set a path for a class that extends View in xml? Android-Studio

I found the following class https://android.googlesource.com/device/google/accessory/demokit/+/4de77996b19a3851675080072f029b0c7d0865ff/app/src/com/google/android/DemoKit/ColorWheel.java , but I don't really know how to display it. I am quite new to android and I haven't used something like this until now. Could you tell me how to make that class display in an activity ?

When I do this

<com.google.android.packageName.ColorWheel> android:id="@+id/view" android:layout_width="fill_parent" android:layout_height="wrap_content" </com.google.android.packageName.ColorWheel> 

You'll need to use the fully qualified path of the custom view in your layout xml.

So this:

<com.google.android.DemoKit.ColorWheel></com.google.android.DemoKit.ColorWheel>

instead of just this:

<ColorWheel></ColorWheel>

Note that you'll need to modify the package to match where the class exists in your project, ie com.google.android.DemoKit will need to be changed to whatever package this View subclass exists in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM