Android 14에는 개발자를 위한 훌륭한 기능과 API가 도입되었습니다. 다음은 앱의 기능을 알아보고 관련 API를 시작하는 데 도움이 됩니다.
추가된 API, 수정된 API, 삭제된 API에 관한 자세한 목록은 API 차이점 보고서를 참고하세요. 추가된 API에 관한 자세한 내용은 Android API 참조를 참고하세요. Android 14의 경우 API 수준 34에 추가된 API를 찾아보세요. 플랫폼 변경이 앱에 영향을 줄 수 있는 분야에 관해 알아보려면 Android 14를 타겟팅하는 앱 및 모든 앱의 Android 14 동작 변경사항을 확인해야 합니다.
다국어 지원
앱별 언어 설정
Android 14 expands on the per-app language features that were introduced in Android 13 (API level 33) with these additional capabilities:
Automatically generate an app's
localeConfig: Starting with Android Studio Giraffe Canary 7 and AGP 8.1.0-alpha07, you can configure your app to support per-app language preferences automatically. Based on your project resources, the Android Gradle plugin generates theLocaleConfigfile and adds a reference to it in the final manifest file, so you no longer have to create or update the file manually. AGP uses the resources in theresfolders of your app modules and any library module dependencies to determine the locales to include in theLocaleConfigfile.Dynamic updates for an app's
localeConfig: Use thesetOverrideLocaleConfig()andgetOverrideLocaleConfig()methods inLocaleManagerto dynamically update your app's list of supported languages in the device's system settings. Use this flexibility to customize the list of supported languages per region, run A/B experiments, or provide an updated list of locales if your app utilizes server-side pushes for localization.App language visibility for input method editors (IMEs): IMEs can utilize the
getApplicationLocales()method to check the language of the current app and match the IME language to that language.
Grammatical Inflection API
30억 명의 사용자가 성별이 지정된 언어를 사용합니다. 이 언어는 이야기하는 사람과 사물의 성별에 따라 문법적 카테고리(예: 명사, 동사, 형용사, 전치사)가 영향을 받는 언어입니다. 일반적으로 성별이 지정된 많은 언어에서 남성형 문법적 성별을 기본 성별이나 일반 성별로 사용합니다.
여성을 남성형 문법적 성별로 언급하는 등 잘못된 문법적 성별로 사용자를 언급하면 사용자의 실적과 태도에 부정적인 영향을 미칠 수 있습니다. 반면 사용자의 문법적 성별을 올바르게 반영하는 언어로 된 UI는 사용자 참여를 개선하고 보다 맞춤설정되고 자연스러운 사용자 환경을 제공할 수 있습니다.
성별이 지정된 언어의 사용자 중심 UI를 빌드할 수 있도록 Android 14에서는 앱 리팩터링 없이 문법적 성별에 관한 지원을 추가할 수 있는 Grammatical Inflection API를 도입합니다.
지역 설정
Regional preferences enable users to personalize temperature units, the first day of the week, and numbering systems. A European living in the United States might prefer temperature units to be in Celsius rather than Fahrenheit and for apps to treat Monday as the beginning of the week instead of the US default of Sunday.
New Android Settings menus for these preferences provide users with a
discoverable and centralized location to change app preferences. These
preferences also persist through backup and restore. Several APIs and
intents—such as
getTemperatureUnit
and
getFirstDayOfWeek—
grant your app read access to user preferences, so your app can adjust how it
displays information. You can also register a
BroadcastReceiver on
ACTION_LOCALE_CHANGED
to handle locale configuration changes when regional preferences change.
To find these settings, open the Settings app and navigate to System > Languages & input > Regional preferences.
접근성
비선형 글꼴 크기 200%로 조정
Android 14부터 시스템은 글꼴 크기를 최대 200%까지 지원하므로 사용자에게 추가 접근성 옵션을 제공할 수 있습니다.
화면의 큰 텍스트 요소가 너무 커지지 않도록 시스템에서는 비선형 크기 조정 곡선을 적용합니다. 이 크기 조정 전략은 큰 텍스트가 작은 텍스트와 동일한 비율로 조정되지 않음을 의미합니다. 비선형 글꼴 크기 조정은 다양한 크기의 요소 간에 비례 계층 구조를 유지하는 동시에 높은 수준으로 크기가 조정되는 선형 텍스트 문제 (예: 텍스트가 잘리거나 너무 큰 디스플레이 크기로 인해 텍스트를 읽기 어려워지는 경우)를 완화하는 데 도움이 됩니다.
비선형 글꼴 크기 조정으로 앱 테스트
이미 확장 가능 픽셀 (sp) 단위를 사용하여 텍스트 크기를 정의하는 경우 이러한 추가 옵션과 크기 조정 개선사항이 앱의 텍스트에 자동으로 적용됩니다. 하지만 앱이 글꼴 크기를 올바르게 적용하고 사용성에 영향을 미치지 않으면서 더 큰 글꼴 크기를 수용할 수 있는지 확인하려면 최대 글꼴 크기 (200%)를 사용 설정하여 UI 테스트를 실행해야 합니다.
200% 글꼴 크기를 사용 설정하려면 다음 단계를 따르세요.
- 설정 앱을 열고 접근성 > 디스플레이 크기 및 텍스트로 이동합니다.
- 글꼴 크기 옵션의 경우 이 섹션에 제공되는 이미지와 같이 최대 글꼴 크기 설정이 사용 설정될 때까지 더하기(+) 아이콘을 탭합니다.
텍스트 크기에 조정된 픽셀(sp) 단위 사용
항상 sp 단위로 텍스트 크기를 지정해야 합니다. 앱에서 sp 단위를 사용하면 Android에서는 사용자의 기본 텍스트 크기를 적용하고 적절하게 크기를 조정할 수 있습니다.
패딩에 sp 단위를 사용하거나 암시적 패딩을 가정하여 뷰 높이를 정의하지 마세요. 비선형 글꼴 크기 조정 sp 치수는 비례하지 않을 수 있으므로 4sp + 20sp가 24sp와 같지 않을 수 있습니다.
조정된 픽셀(sp) 단위 변환
TypedValue.applyDimension()을 사용하여 sp 단위에서 픽셀로 변환하고 TypedValue.deriveDimension()을 사용하여 픽셀을 sp로 변환합니다. 이러한 메서드는 적절한 비선형 크기 조정 곡선을 자동으로 적용합니다.
Configuration.fontScale 또는 DisplayMetrics.scaledDensity를 사용하여 수식을 하드코딩하지 마세요. 글꼴 크기 조정이 비선형이므로 scaledDensity 필드가 더 이상 정확하지 않습니다. 글꼴은 더 이상 단일 스칼라 값으로 확장되지 않으므로 fontScale 필드는 정보 제공 목적으로만 사용해야 합니다.
lineHeight에 sp 단위 사용
항상 dp 대신 sp 단위를 사용하여 android:lineHeight를 정의하여 행 간격이 텍스트와 함께 조정되도록 합니다. 그렇지 않고 텍스트가 sp인데 lineHeight가 dp 또는 px인 경우 크기가 조정되지 않고 답답해 보입니다.
TextView는 의도한 비율이 유지되도록 lineHeight를 자동으로 수정하지만, textSize와 lineHeight가 모두 sp 단위로 정의된 경우에만 가능합니다.
카메라 및 미디어
이미지용 울트라 HDR
Android 14에서는 사진을 찍을 때 센서의 정보를 더 많이 유지하여 생생한 색상과 더 높은 대비를 제공하는 HDR (High Dynamic Range) 이미지를 지원합니다. Android는 JPEG 이미지와 완전히 하위 호환되는 울트라 HDR 형식을 사용하므로 앱이 HDR 이미지와 원활하게 상호 운용하여 필요에 따라 표준 동적 범위 (SDR)로 표시할 수 있습니다.
앱이 매니페스트 항목을 통해 또는 런타임에 Window.setColorMode() 호출을 통해 활동 창에 HDR UI를 사용하도록 선택하면 UI에서 이러한 이미지를 HDR로 렌더링하는 작업은 프레임워크에서 자동으로 실행됩니다. 지원되는 기기에서 압축된 울트라 HDR 스틸 이미지를 캡처할 수도 있습니다. 센서에서 더 많은 색상을 복구하면 후반 작업에서 더 유연하게 수정할 수 있습니다. 울트라 HDR 이미지와 연결된 Gainmap를 사용하여 OpenGL 또는 Vulkan을 사용하여 렌더링할 수 있습니다.
카메라 확장 프로그램의 확대/축소, 초점, Postview 등
Android 14에서는 카메라 확장 프로그램을 업그레이드하고 개선하여 앱이 더 긴 처리 시간을 처리할 수 있도록 지원합니다. 이를 통해 지원되는 기기에서 저조도 사진과 같은 컴퓨팅 집약적인 알고리즘을 사용하여 이미지를 개선할 수 있습니다. 이러한 기능을 통해 사용자는 카메라 확장 기능을 사용할 때 더욱 강력한 환경을 경험할 수 있습니다. 이러한 개선사항의 예는 다음과 같습니다.
- 동적 스틸 캡처 처리 지연 시간 추정치는 현재 장면과 환경 조건을 기반으로 훨씬 더 정확한 스틸 캡처 지연 시간 추정치를 제공합니다.
CameraExtensionSession.getRealtimeStillCaptureLatency()를 호출하여 지연 시간 추정 메서드가 두 개인StillCaptureLatency객체를 가져옵니다.getCaptureLatency()메서드는onCaptureStarted와onCaptureProcessStarted()간의 예상 지연 시간을 반환하고getProcessingLatency()메서드는onCaptureProcessStarted()와 사용 가능한 최종 처리된 프레임 간의 예상 지연 시간을 반환합니다. - 앱이 장기 실행 스틸 캡처 처리 작업의 현재 진행 상황을 표시할 수 있도록 캡처 진행 상황 콜백을 지원합니다.
CameraExtensionCharacteristics.isCaptureProcessProgressAvailable에서 이 기능을 사용할 수 있는지 확인할 수 있으며, 사용할 수 있는 경우 진행률 (0~100)이 매개변수로 전달되는onCaptureProcessProgressed()콜백을 구현합니다. 확장 프로그램별 메타데이터(예:
CaptureRequest.EXTENSION_STRENGTH:EXTENSION_BOKEH를 사용하여 배경 흐리게 처리의 양과 같은 확장 프로그램 효과의 양을 조정하는 데 사용)카메라 확장 프로그램의 스틸 캡처를 위한 포스트뷰 기능으로, 최종 이미지보다 처리가 덜된 이미지를 더 빠르게 제공합니다. 확장 프로그램의 처리 지연 시간이 늘어난 경우 UX를 개선하기 위해 포스트뷰 이미지를 자리표시자로 제공하고 나중에 최종 이미지로 전환할 수 있습니다.
CameraExtensionCharacteristics.isPostviewAvailable를 사용하여 이 기능을 사용할 수 있는지 확인할 수 있습니다. 그런 다음OutputConfiguration를ExtensionSessionConfiguration.setPostviewOutputConfiguration에 전달할 수 있습니다.더 최적화되고 전력 효율적인 미리보기 렌더링 경로를 허용하는
SurfaceView지원확장 프로그램 사용 중에 탭하여 초점 맞추기 및 확대/축소를 지원합니다.
인센서 줌
CameraCharacteristics의 REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE에 SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW가 포함된 경우 앱은 고급 센서 기능을 사용하여 스트림 사용 사례가 CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW로 설정된 RAW 타겟과 함께 CaptureRequest를 사용하여 잘린 RAW 스트림에 전체 시야와 동일한 픽셀을 제공할 수 있습니다.
요청 재정의 컨트롤을 구현하면 업데이트된 카메라에서 다른 카메라 컨트롤이 준비되기 전에도 사용자에게 확대/축소 컨트롤을 제공할 수 있습니다.
무손실 USB 오디오
Android 14에서는 USB 유선 헤드셋을 통한 오디오필 수준의 환경을 위한 무손실 오디오 형식을 지원합니다. USB 기기에서 기본 믹서 속성을 쿼리하고, 기본 믹서 속성 변경에 관한 리스너를 등록하고, AudioMixerAttributes 클래스를 사용하여 믹서 속성을 구성할 수 있습니다. 이 클래스는 채널 마스크, 샘플링 레이트, 오디오 믹서의 동작과 같은 형식을 나타냅니다. 이 클래스를 사용하면 믹싱, 볼륨 조정 또는 효과 처리 없이 오디오를 직접 전송할 수 있습니다.
개발자 생산성 및 도구
인증 관리자
Android 14에서는 인증 관리자를 플랫폼 API로 추가하고 Google Play 서비스를 사용하는 Jetpack 라이브러리를 통해 Android 4.4 (API 수준 19) 기기까지 추가로 지원합니다. 인증 관리자의 목표는 사용자가 구성한 사용자 인증 정보 제공업체로 사용자 인증 정보를 검색하고 저장하는 API를 사용하여 사용자가 더 쉽게 로그인할 수 있도록 하는 것입니다. 인증 관리자는 단일 API에서 사용자 이름과 비밀번호, 패스키, 제휴 로그인 솔루션 (예: Google 계정으로 로그인)과 같은 멀티 로그인 방식을 지원합니다.
패스키는 여러 이점을 제공합니다. 예를 들어 패스키는 업계 표준을 기반으로 구축되며, 다양한 운영체제와 브라우저 생태계에서 작동할 수 있으며, 웹사이트와 앱 모두에서 사용할 수 있습니다.
자세한 내용은 인증 관리자 및 패스키 문서 및 인증 관리자 및 패스키에 관한 블로그 게시물을 참고하세요.
헬스 커넥트
Health Connect is an on-device repository for user health and fitness data. It allows users to share data between their favorite apps, with a single place to control what data they want to share with these apps.
On devices running Android versions prior to Android 14, Health Connect is available to download as an app on the Google Play store. Starting with Android 14, Health Connect is part of the platform and receives updates through Google Play system updates without requiring a separate download. With this, Health Connect can be updated frequently, and your apps can rely on Health Connect being available on devices running Android 14 or higher. Users can access Health Connect from the Settings in their device, with privacy controls integrated into the system settings.
Health Connect includes several new features in Android 14, such as exercise routes, allowing users to share a route of their workout which can be visualized on a map. A route is defined as a list of locations saved within a window of time, and your app can insert routes into exercise sessions, tying them together. To ensure that users have complete control over this sensitive data, users must allow sharing individual routes with other apps.
For more information, see the Health Connection documentation and the blogpost on What's new in Android Health.
OpenJDK 17 업데이트
Android 14 continues the work of refreshing Android's core libraries to align with the features in the latest OpenJDK LTS releases, including both library updates and Java 17 language support for app and platform developers.
The following features and improvements are included:
- Updated approximately 300
java.baseclasses to Java 17 support. - Text Blocks, which introduce multi-line string literals to the Java programming language.
- Pattern Matching for instanceof, which allows an object to
be treated as having a specific type in an
instanceofwithout any additional variables. - Sealed classes, which allow you restrict which classes and interfaces can extend or implement them.
Thanks to Google Play system updates (Project Mainline), over 600 million devices are enabled to receive the latest Android Runtime (ART) updates that include these changes. This is part of our commitment to give apps a more consistent, secure environment across devices, and to deliver new features and capabilities to users independent of platform releases.
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
앱 스토어 개선사항
Android 14 introduces several PackageInstaller APIs that
allow app stores to improve their user experience.
Request install approval before downloading
Installing or updating an app might require user approval.
For example, when an installer making use of the
REQUEST_INSTALL_PACKAGES permission attempts to install a
new app. In prior Android versions, app stores can only request user approval
after APKs are written to the install session and the
session is committed.
Starting with Android 14, the requestUserPreapproval()
method lets installers request user approval before committing the install
session. This improvement lets an app store defer downloading any APKs until
after the installation has been approved by the user. Furthermore, once a user
has approved installation, the app store can download and install the app in the
background without interrupting the user.
Claim responsibility for future updates
The setRequestUpdateOwnership() method allows an installer
to indicate to the system that it intends to be responsible for future updates
to an app it is installing. This capability enables update ownership
enforcement, meaning that only the update owner is permitted
to install automatic updates to the app. Update ownership enforcement helps to
ensure that users receive updates only from the expected app store.
Any other installer, including those making use of the
INSTALL_PACKAGES permission, must receive explicit user
approval in order to install an update. If a user decides to proceed with an
update from another source, update ownership is lost.
Update apps at less-disruptive times
App stores typically want to avoid updating an app that is actively in use because this leads to the app's running processes being killed, which potentially interrupts what the user was doing.
Starting with Android 14, the InstallConstraints API
gives installers a way to ensure that their app updates happen at an opportune
moment. For example, an app store can call the
commitSessionAfterInstallConstraintsAreMet() method to
make sure that an update is only committed when the user is no longer
interacting with the app in question.
Seamlessly install optional splits
With split APKs, features of an app can be delivered in separate APK files,
rather than as a monolithic APK. Split APKs allow app stores to optimize the
delivery of different app components. For example, app stores might optimize
based on the properties of the target device. The
PackageInstaller API has supported splits since its
introduction in API level 22.
In Android 14, the setDontKillApp() method allows an
installer to indicate that the app's running processes shouldn't be killed when
new splits are installed. App stores can use this feature to seamlessly install
new features of an app while the user is using the app.
앱 메타데이터 번들
Android 14부터 Android 패키지 설치 프로그램을 사용하면 데이터 보안 관행과 같은 앱 메타데이터를 지정하여 Google Play와 같은 앱 스토어 페이지에 포함할 수 있습니다.
사용자가 기기 스크린샷을 찍을 때 감지
스크린샷 감지를 위한 보다 표준화된 환경을 만들기 위해 Android 14에서는 개인 정보 보호 스크린샷 감지 API를 도입했습니다. 이 API를 사용하면 앱에서 활동별로 콜백을 등록할 수 있습니다. 활동이 표시되는 동안 사용자가 스크린샷을 찍으면 이러한 콜백이 호출되고 사용자에게 알림이 전송됩니다.
사용자 환경
Sharesheet 맞춤 작업 및 개선된 순위 지정
Android 14에서는 맞춤 앱 작업과 사용자에게 더 많은 정보를 제공하는 미리보기 결과를 지원하도록 시스템 Sharesheet를 업데이트합니다.
맞춤 작업 추가
Android 14에서는 앱에서 호출하는 시스템 Sharesheet에 맞춤 작업을 추가할 수 있습니다.
직접 공유 타겟의 순위 향상
Android 14는 앱에서 더 많은 신호를 사용하여 직접 공유 타겟의 순위를 결정하고 사용자에게 더 유용한 결과를 제공합니다. 순위에 가장 유용한 신호를 제공하려면 직접 공유 타겟의 순위 향상에 관한 안내를 따르세요. 커뮤니케이션 앱은 발신 및 수신 메시지의 단축키 사용을 보고할 수도 있습니다.
뒤로 탐색 예측을 위한 내장 및 맞춤 애니메이션 지원
Android 13 introduced the predictive back-to-home animation behind a developer option. When used in a supported app with the developer option enabled, swiping back shows an animation indicating that the back gesture exits the app back to the home screen.
Android 14 includes multiple improvements and new guidance for Predictive Back:
- You can set
android:enableOnBackInvokedCallback=trueto opt in to predictive back system animations per-Activity instead of for the entire app. - We've added new system animations to accompany the back-to-home animation from Android 13. The new system animations are cross-activity and cross-task, which you get automatically after migrating to Predictive Back.
- We've added new Material Component animations for Bottom sheets, Side sheets, and Search.
- We've created design guidance for creating custom in-app animations and transitions.
- We've added new APIs to support custom in-app transition animations:
handleOnBackStarted,handleOnBackProgressed,handleOnBackCancelledinOnBackPressedCallbackonBackStarted,onBackProgressed,onBackCancelledinOnBackAnimationCallback- Use
overrideActivityTransitioninstead ofoverridePendingTransitionfor transitions that respond as the user swipes back.
With this Android 14 preview release, all features of Predictive Back remain behind a developer option. See the developer guide to migrate your app to predictive back, as well as the developer guide to creating custom in-app transitions.
대형 화면 기기 제조업체 앱별 재정의
앱별 재정의를 사용하면 기기 제조업체가 대형 화면 기기에서 앱의 동작을 변경할 수 있습니다. 예를 들어 FORCE_RESIZE_APP 재정의는 앱 매니페스트에 resizeableActivity="false"가 설정되어 있더라도 디스플레이 크기에 맞게 앱의 크기를 조절하도록 시스템에 지시합니다 (크기 호환성 모드 피하기).
재정의는 대형 화면에서 사용자 환경을 개선하기 위한 것입니다.
새 매니페스트 속성을 사용하면 앱에 대한 일부 기기 제조업체 재정의를 사용 중지할 수 있습니다.
대형 화면 사용자 앱별 재정의
앱별 재정의는 대형 화면 기기에서 앱의 동작을 변경합니다. 예를 들어 OVERRIDE_MIN_ASPECT_RATIO_LARGE 기기 제조업체 재정의는 앱 구성과 관계없이 앱 가로세로 비율을 16:9로 설정합니다.
Android 14 QPR1을 사용하면 사용자가 대형 화면 기기에서 새 설정 메뉴를 통해 앱별 재정의를 적용할 수 있습니다.
앱 화면 공유
앱 화면 공유를 사용하면 사용자가 화면 콘텐츠를 녹화하는 동안 전체 기기 화면 대신 앱 창을 공유할 수 있습니다.
앱 화면 공유를 사용하면 상태 표시줄, 탐색 메뉴, 알림, 기타 시스템 UI 요소가 공유 디스플레이에서 제외됩니다. 선택한 앱의 콘텐츠만 공유됩니다.
앱 화면 공유를 사용하면 사용자가 여러 앱을 실행하면서 콘텐츠 공유를 단일 앱으로 제한하여 생산성과 개인 정보 보호를 개선할 수 있습니다.
Pixel 8 Pro의 Gboard에서 LLM 기반 스마트 답장
12월 기능 업데이트가 적용된 Pixel 8 Pro 기기에서 개발자는 Google Tensor에서 실행되는 온디바이스 대규모 언어 모델 (LLM)을 기반으로 하는 Gboard의 고품질 스마트 답장을 사용해 볼 수 있습니다.
이 기능은 WhatsApp, Line, KakaoTalk에서 미국 영어로 제한된 미리보기로 제공됩니다. Gboard를 키보드로 사용하는 Pixel 8 Pro 기기를 사용해야 합니다.
이 기능을 사용해 보려면 먼저 설정 > 개발자 옵션 > AiCore 설정 > Aicore Persistent 사용 설정에서 기능을 사용 설정하세요.
그런 다음 지원되는 앱에서 대화를 열어 수신 메시지에 대한 응답으로 Gboard의 추천 표시줄에 LLM 기반 스마트 답장이 표시되는지 확인합니다.
그래픽
경로를 쿼리하고 보간할 수 있음
Android의 Path API는 벡터 그래픽을 만들고 렌더링하기 위한 강력하고 유연한 메커니즘으로, 경로를 획 처리하거나 채우고, 선분이나 이차 또는 삼차 곡선으로 경로를 구성하고, 불리언 연산을 실행하여 훨씬 더 복잡한 도형을 가져오거나 이 모든 작업을 동시에 실행할 수 있습니다. 한 가지 제한사항은 경로 객체에 실제로 무엇이 있는지 찾을 수 있다는 것입니다. 객체의 내부는 생성 후 호출자에게 불투명합니다.
Path를 만들려면 moveTo(), lineTo(), cubicTo()와 같은 메서드를 호출하여 경로 세그먼트를 추가하세요. 그러나 이 경로에 세그먼트가 무엇인지 물어볼 방법이 없으므로 생성 시 해당 정보를 유지해야 합니다.
Android 14부터 경로를 쿼리하여 그 안에 포함된 항목을 확인할 수 있습니다.
먼저 Path.getPathIterator API를 사용하여 PathIterator 객체를 가져와야 합니다.
Kotlin
val path = Path().apply { moveTo(1.0f, 1.0f) lineTo(2.0f, 2.0f) close() } val pathIterator = path.pathIterator
자바
Path path = new Path(); path.moveTo(1.0F, 1.0F); path.lineTo(2.0F, 2.0F); path.close(); PathIterator pathIterator = path.getPathIterator();
그런 다음 PathIterator를 호출하여 세그먼트를 하나씩 반복하면서 각 세그먼트에 필요한 모든 데이터를 검색할 수 있습니다. 이 예에서는 데이터를 패키징하는 PathIterator.Segment 객체를 사용합니다.
Kotlin
for (segment in pathIterator) { println("segment: ${segment.verb}, ${segment.points}") }
자바
while (pathIterator.hasNext()) { PathIterator.Segment segment = pathIterator.next(); Log.i(LOG_TAG, "segment: " + segment.getVerb() + ", " + segment.getPoints()); }
PathIterator에는 포인트 데이터를 보유할 버퍼를 전달할 수 있는 비할당 버전의 next()도 있습니다.
Path 데이터 쿼리에 관한 중요한 사용 사례 중 하나는 보간 유형입니다. 예를 들어 서로 다른 두 경로 간에 애니메이션을 적용하거나 모핑할 수 있습니다. 이러한 사용 사례를 더욱 단순화하기 위해 Android 14에는 Path에 interpolate() 메서드도 포함되어 있습니다. 두 경로의 내부 구조가 같다고 가정하면 interpolate() 메서드는 보간된 결과를 사용하여 새 Path를 만듭니다. 이 예에서는 path 및 otherPath 사이의 도형이 중간(선형 보간 유형 0.5)인 경로를 반환합니다.
Kotlin
val interpolatedResult = Path() if (path.isInterpolatable(otherPath)) { path.interpolate(otherPath, .5f, interpolatedResult) }
자바
Path interpolatedResult = new Path(); if (path.isInterpolatable(otherPath)) { path.interpolate(otherPath, 0.5F, interpolatedResult); }
Jetpack graphics-path 라이브러리를 사용하면 이전 버전의 Android에서도 유사한 API를 사용할 수 있습니다.
버텍스 및 프래그먼트 셰이더가 있는 맞춤 메시
Android has long supported drawing triangle meshes with custom shading, but the input mesh format has been limited to a few predefined attribute combinations. Android 14 adds support for custom meshes, which can be defined as triangles or triangle strips, and can, optionally, be indexed. These meshes are specified with custom attributes, vertex strides, varying, and vertex and fragment shaders written in AGSL.
The vertex shader defines the varyings, such as position and color, while the
fragment shader can optionally define the color for the pixel, typically by
using the varyings created by the vertex shader. If color is provided by the
fragment shader, it is then blended with the current Paint
color using the blend mode selected when
drawing the mesh. Uniforms can be passed
into the fragment and vertex shaders for additional flexibility.
캔버스의 하드웨어 버퍼 렌더러
Android의 Canvas API를 사용하여 하드웨어 가속으로 HardwareBuffer에 그리는 것을 지원하기 위해 Android 14에서는 HardwareBufferRenderer를 도입합니다. 이 API는
시스템과의 통신이 포함된 사용 사례에 특히 유용합니다
짧은 지연 시간을 위해 SurfaceControl를 통한 컴포지터
있습니다.