自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
不使用车载设备界面库开发应用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
车载设备界面库 (car-ui-library) 是一个自洽的车载设备界面库,可由 OEM 自定义。Google 强烈建议您使用 car-ui-library 来创建应用。如果这种方式不可行,有两种替代方案:
- 从 Android 12 开始,您可以使用 car-ui-library 的子集
car-rotary-lib
。
- 在 Android 11 中,您必须实现自己的
FocusParkingView
、FocusArea
和 DirectManipulationHelper
,如下所述。
实现 FocusParkingView
您可以实现自己的 FocusParkingView
,也可以将该类从 car-ui-library 复制到您的项目中。
如需实现 FocusParkingView
,请执行以下操作:
- 对无障碍功能类名称进行硬编码,使
RotaryService
能够识别它:
@Override
public CharSequence getAccessibilityClassName() {
return "com.android.car.ui.FocusParkingView";
}
实现 FocusArea
与 FocusParkingView
一样,您可以实现自己的 FocusArea
,也可以将该类从 car-ui-library 复制到您的项目中。
如需实现 FocusArea
,请执行以下操作:
- 对无障碍功能类名称进行硬编码,使旋转服务能够识别它:
@Override
public CharSequence getAccessibilityClassName() {
return "com.android.car.ui.FocusArea";
}
实现 DirectManipulationHelper
这是一个实用程序类。您可以将该类从 car-ui-library 复制到您的项目中。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Develop apps without the Car UI library\n\nThe\n[Car UI Library (car-ui-library)](/docs/automotive/hmi/car_ui)\nis a self-consistent automotive UI library that can be customized by OEMs. Google strongly\nrecommends you use the car-ui-library to create your app. If this isn't feasible, there are\ntwo alternatives:\n\n- From Android 12, you can use `car-rotary-lib`, a subset of car-ui-library.\n- On Android 11, you MUST implement your own `FocusParkingView`, `FocusArea`, and `DirectManipulationHelper` as described below.\n\nImplement FocusParkingView\n--------------------------\n\nYou either can implement your own `FocusParkingView` or copy the class from the\ncar-ui-library to your project.\n\nTo implement `FocusParkingView`:\n\n1. Hard code the accessibility class name so that the `RotaryService` can recognize it: \n\n ```\n @Override\n public CharSequence getAccessibilityClassName() {\n return \"com.android.car.ui.FocusParkingView\";\n }\n ```\n\nImplement FocusArea\n-------------------\n\nLike `FocusParkingView`, you can either implement your own `FocusArea`\nor copy the class from the car-ui-library to your project.\n\nTo implement `FocusArea`:\n\n1. Hard code the accessibility class name so that rotary service can recognize it: \n\n ```\n @Override\n public CharSequence getAccessibilityClassName() {\n return \"com.android.car.ui.FocusArea\";\n }\n ```\n\nImplement DirectManipulationHelper\n----------------------------------\n\nThis is a utility class. You can copy the class from the car-ui-library to your project."]]