Creating customs controls in Android

2019-08-29 05:24发布

I want to create my own custom controls in Android application and use them in this way: In the XML file:

<MyButton .... />

I would like to define MyButton some where in the resources XML

1条回答
相关推荐>>
2楼-- · 2019-08-29 05:40

Create your own subclass of View (e.g., com.ofirbit.MyButton) and then reference it in your layouts (e.g., <com.ofirbit.MyButton android:id="..." />). Here is an Android library project and demonstration sub-project showing an implementation of a custom ColorMixer widget and its use in an application. The details of how to implement one of these can be found in some Android books, the Android documentation, and perhaps elsewhere.

查看更多
登录 后发表回答