如何在 Android 中创建自定义控件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1046256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:38:06  来源:igfitidea点击:

How can I create custom controls in Android?

androidcontrols

提问by SvenFinke

I would like to create a custom control in my Android App. It will be a circular control with some smaller moveable circles that will indicate a specific value.

我想在我的 Android 应用程序中创建一个自定义控件。它将是一个圆形控件,带有一些较小的可移动圆圈,用于指示特定值。

Is there a way to realize this?

有没有办法实现这一点?

Are there at least some nice tutorials where I can read how to create a custom control?

是否至少有一些不错的教程可以让我阅读如何创建自定义控件?

回答by Josef Pfleger

Have a look at the custom componentssection of the Android Dev Guide. The usual approach is to extend a Viewand override applicable methods.

查看Android 开发指南的自定义组件部分。通常的方法是扩展 aView并覆盖适用的方法。