يقدّم Android 14 ميزات وواجهات برمجة تطبيقات رائعة للمطوّرين. لمعرفة المزيد عن ميزات تطبيقاتك وبدء استخدام واجهات برمجة التطبيقات ذات الصلة،
للحصول على قائمة مفصّلة بواجهات برمجة التطبيقات التي تمت إضافتها وتعديلها وإزالتها، اطّلِع على تقرير الاختلافات في واجهة برمجة التطبيقات. للحصول على تفاصيل حول واجهات برمجة التطبيقات المُضافة، انتقِل إلى مرجع واجهة برمجة تطبيقات Android. بالنسبة إلى الإصدار 14 من نظام التشغيل Android، ابحث عن واجهات برمجة التطبيقات التي تمت إضافتها في المستوى 34. لمعرفة المجالات التي قد تؤثر فيها تغييرات النظام الأساسي في تطبيقاتك، يمكنك الاطّلاع على التغييرات في السلوك في 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 theLocaleConfig
file 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 theres
folders of your app modules and any library module dependencies to determine the locales to include in theLocaleConfig
file.Dynamic updates for an app's
localeConfig
: Use thesetOverrideLocaleConfig()
andgetOverrideLocaleConfig()
methods inLocaleManager
to 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.
واجهة برمجة تطبيقات التدفّق النحوي
3 billion people speak gendered languages: languages where grammatical categories—such as nouns, verbs, adjectives, and prepositions—inflect according to the gender of people and objects you talk to or about. Traditionally, many gendered languages use masculine grammatical gender as the default or generic gender.
Addressing users in the wrong grammatical gender, such as addressing women in masculine grammatical gender, can negatively impact their performance and attitude. In contrast, a UI with language that correctly reflects the user's grammatical gender can improve user engagement and provide a more personalized and natural-sounding user experience.
لمساعدتك في إنشاء واجهة مستخدم تركِّز على المستخدم في اللغات التي تراعي نوع الجنس، يقدِّم Android 14 واجهة برمجة التطبيقات النحوية التي تتيح لك إضافة دعم للنوع النحوي بدون إعادة تنظيم تطبيقك.
الإعدادات المفضّلة للمنطقة
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.
![](https://developer.android.com/static/about/versions/14/images/regional-preferences.png?authuser=8&hl=ar)
![](https://developer.android.com/static/about/versions/14/images/regional-preferences-temperature.png?authuser=8&hl=ar)
تسهيل الاستخدام
تكبير الخط غير الخطي إلى 200%
Starting in Android 14, the system supports font scaling up to 200%, providing low-vision users with additional accessibility options that align with Web Content Accessibility Guidelines (WCAG).
To prevent large text elements on screen from scaling too large, the system applies a nonlinear scaling curve. This scaling strategy means that large text doesn't scale at the same rate as smaller text. Nonlinear font scaling helps preserve the proportional hierarchy between elements of different sizes while mitigating issues with linear text scaling at high degrees (such as text being cut off or text that becomes harder to read due to an extremely large display sizes).
Test your app with nonlinear font scaling
![](https://developer.android.com/static/images/about/versions/14/accessibility-font-options.png?authuser=8&hl=ar)
If you already use scaled pixels (sp) units to define text sizing, then these additional options and scaling improvements are applied automatically to the text in your app. However, you should still perform UI testing with the maximum font size enabled (200%) to ensure that your app applies the font sizes correctly and can accommodate larger font sizes without impacting usability.
To enable 200% font size, follow these steps:
- Open the Settings app and navigate to Accessibility > Display size and text.
- For the Font size option, tap the plus (+) icon until the maximum font size setting is enabled, as shown in the image that accompanies this section.
Use scaled pixel (sp) units for text-sizes
Remember to always specify text sizes in sp units. When your app uses sp units, Android can apply the user's preferred text size and scale it appropriately.
Don't use sp units for padding or define view heights assuming implicit padding: with nonlinear font scaling sp dimensions might not be proportional, so 4sp + 20sp might not equal 24sp.
Convert scaled pixel (sp) units
Use TypedValue.applyDimension()
to convert from sp units
to pixels, and use TypedValue.deriveDimension()
to
convert pixels to sp. These methods apply the appropriate nonlinear scaling
curve automatically.
Avoid hardcoding equations using
Configuration.fontScale
or
DisplayMetrics.scaledDensity
. Because font scaling is
nonlinear, the scaledDensity
field is no longer accurate. The fontScale
field should be used for informational purposes only because fonts are no longer
scaled with a single scalar value.
Use sp units for lineHeight
Always define android:lineHeight
using sp units instead
of dp, so the line height scales along with your text. Otherwise, if your text
is sp but your lineHeight
is in dp or px, it doesn't scale and looks cramped.
TextView automatically corrects the lineHeight
so that your intended
proportions are preserved, but only if both textSize
and lineHeight
are
defined in sp units.
الكاميرا والوسائط
دقة HDR فائقة للصور
![](https://developer.android.com/static/images/about/versions/14/SDR-HDR-compare.png?authuser=8&hl=ar)
Android 14 adds support for High Dynamic Range (HDR) images that retain more of the information from the sensor when taking a photo, which enables vibrant colors and greater contrast. Android uses the Ultra HDR format, which is fully backward compatible with JPEG images, allowing apps to seamlessly interoperate with HDR images, displaying them in Standard Dynamic Range (SDR) as needed.
Rendering these images in the UI in HDR is done automatically by the framework
when your app opts in to using HDR UI for its Activity Window, either through a
manifest entry or at runtime by calling
Window.setColorMode()
. You can also capture compressed Ultra
HDR still images on supported devices. With more colors recovered
from the sensor, editing in post can be more flexible. The
Gainmap
associated with Ultra HDR images can be used to render
them using OpenGL or Vulkan.
ميزات التكبير أو التصغير والتركيز وعرض المشاركات والمزيد في إضافات الكاميرا
Android 14 upgrades and improves camera extensions, allowing apps to handle longer processing times, which enables improved images using compute-intensive algorithms like low-light photography on supported devices. These features give users an even more robust experience when using camera extension capabilities. Examples of these improvements include:
- Dynamic still capture processing latency estimation provides much more
accurate still capture latency estimates based on the current scene and
environment conditions. Call
CameraExtensionSession.getRealtimeStillCaptureLatency()
to get aStillCaptureLatency
object that has two latency estimation methods. ThegetCaptureLatency()
method returns the estimated latency betweenonCaptureStarted
andonCaptureProcessStarted()
, and thegetProcessingLatency()
method returns the estimated latency betweenonCaptureProcessStarted()
and the final processed frame being available. - Support for capture progress callbacks so that apps can display the current
progress of long-running, still-capture processing operations. You can check
if this feature is available with
CameraExtensionCharacteristics.isCaptureProcessProgressAvailable
, and if it is, you implement theonCaptureProcessProgressed()
callback, which has the progress (from 0 to 100) passed in as a parameter. Extension specific metadata, such as
CaptureRequest.EXTENSION_STRENGTH
for dialing in the amount of an extension effect, such as the amount of background blur withEXTENSION_BOKEH
.Postview Feature for Still Capture in camera extensions, which provides a less-processed image more quickly than the final image. If an extension has increased processing latency, a postview image could be provided as a placeholder to improve UX and switched out later for the final image. You can check if this feature is available with
CameraExtensionCharacteristics.isPostviewAvailable
. Then you can pass anOutputConfiguration
toExtensionSessionConfiguration.setPostviewOutputConfiguration
.Support for
SurfaceView
allowing for a more optimized and power-efficient preview render path.Support for tap to focus and zoom during extension usage.
تكبير/تصغير ضمن المستشعر
When REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE
in
CameraCharacteristics
contains
SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW
, your app
can use advanced sensor capabilities to give a cropped RAW stream the same
pixels as the full field of view by using a CaptureRequest
with a RAW target that has stream use case set to
CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW
.
By implementing the request override controls, the updated camera gives users
zoom control even before other camera controls are ready.
فقدان الصوت عبر USB
أصبح نظام التشغيل Android 14 متوافقًا مع تنسيقات الصوت بدون فقدان البيانات لتجارب محبي الموسيقى
عبر سماعات الرأس السلكية USB. يمكنك طلب البحث عن سمات أداة المزج المفضّلة في جهاز USB، وتسجيل أداة معالجة التغييرات في سمات المزج المفضّلة، وإعداد سمات أداة المزج باستخدام الفئة AudioMixerAttributes
. وتمثل هذه الفئة التنسيق، مثل قناع القناة ومعدّل العينة وسلوك أداة مزج الصوت. وتتيح هذه الفئة إرسال المحتوى الصوتي مباشرةً بدون خلط أو تعديل في الحجم أو تأثيرات للمعالجة.
أدوات وإنتاجية المطوّرين
مدير بيانات الاعتماد
يضيف نظام التشغيل Android 14 مدير بيانات الاعتماد كواجهة برمجة تطبيقات للنظام الأساسي، مع دعم إضافي لأجهزة Android 4.4 (المستوى 19 من واجهة برمجة التطبيقات) من خلال مكتبة Jetpack التي تستخدم "خدمات Google Play". يهدف "مدير بيانات الاعتماد" إلى تسهيل عملية تسجيل الدخول على المستخدمين باستخدام واجهات برمجة التطبيقات التي تسترد بيانات الاعتماد وتخزّنها من خلال موفري بيانات الاعتماد التي ضبطها المستخدم. يتيح "مدير بيانات الاعتماد" العديد من طرق تسجيل الدخول، بما في ذلك اسم المستخدم وكلمة المرور ومفاتيح المرور وحلول تسجيل الدخول الموحّد (مثل ميزة "تسجيل الدخول باستخدام حساب Google") في واجهة برمجة تطبيقات واحدة.
توفر مفاتيح المرور مزايا عديدة. على سبيل المثال، تم تصميم مفاتيح المرور وفقًا للمعايير المتّبعة في المجال، ويمكن أن تعمل في مختلف أنظمة التشغيل والمنظومات المتكاملة للمتصفّحات، ويمكن استخدامها مع المواقع الإلكترونية والتطبيقات على حدّ سواء.
لمزيد من المعلومات، راجِع مستندات "مدير بيانات الاعتماد ومفاتيح المرور" ومشاركة المدوّنة حول "مدير بيانات الاعتماد" و"مفاتيح المرور".
Health Connect
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.
![](https://developer.android.com/static/images/about/versions/14/health-connect-screen.png?authuser=8&hl=ar)
![](https://developer.android.com/static/images/about/versions/14/health-connect-permissions.png?authuser=8&hl=ar)
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 العمل على تحديث مكتبات Android الأساسية للتوافق مع الميزات الواردة في أحدث إصدارات OpenJDK LTS، بما في ذلك تحديثات المكتبة وإتاحة اللغة في Java 17 لمطوّري التطبيقات والأنظمة الأساسية.
يتم تضمين الميزات والتحسينات التالية:
- تم تحديث حوالي 300 صف
java.base
لتصبح متوافقة مع Java 17. - القوالب النصية، التي تضيف القيم الحرفية للسلاسل المتعددة الأسطر إلى لغة برمجة Java.
- مطابقة النمط لـ exampleof، والتي تسمح بالتعامل مع الكائن على أنه له نوع معين في
instanceof
بدون أي متغيّرات إضافية. - الفئات المحمية: تسمح لك بتقييد الفئات والواجهات التي يمكن توسيعها أو تنفيذها.
بفضل تحديثات نظام Google Play (Project Mainline)، تم تفعيل أكثر من 600 مليون جهاز لتلقّي آخر تحديثات وقت تشغيل Android (ART) التي تتضمّن هذه التغييرات. يشكّل ذلك جزءًا من التزامنا بمنح التطبيقات بيئة أكثر اتساقًا وأمانًا على جميع الأجهزة، فضلاً عن تقديم ميزات وإمكانات جديدة للمستخدمين بشكل مستقل عن إصدارات النظام الأساسي.
إنّ Java وOpenJDK هما علامتان تجاريتان أو علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تحسينات لمتاجر التطبيقات
يقدّم Android 14 العديد من واجهات برمجة تطبيقات PackageInstaller
التي
تسمح لمتاجر التطبيقات بتحسين تجربة المستخدم.
طلب الموافقة على التثبيت قبل التنزيل
قد يتطلب تثبيت أحد التطبيقات أو تحديثه موافقة المستخدم.
على سبيل المثال، عندما يحاول مثبِّت يستخدم إذن REQUEST_INSTALL_PACKAGES
تثبيت
تطبيق جديد. في إصدارات Android السابقة، لا يمكن لمتاجر التطبيقات طلب موافقة المستخدم إلا
بعد كتابة ملفات APK في جلسة التثبيت
وتكون الجلسة الملزَمة.
بدءًا من نظام التشغيل Android 14، تتيح الطريقة requestUserPreapproval()
للمثبِّتين طلب موافقة المستخدم قبل إتمام
جلسة التثبيت. يتيح هذا التحسين لمتجر التطبيقات تأجيل تنزيل أي حِزم APK إلى أن يوافق المستخدم على عملية التثبيت. بالإضافة إلى ذلك، بعد موافقة المستخدم على
تثبيت التطبيق، يمكن لمتجر التطبيقات تنزيل التطبيق وتثبيته في
الخلفية بدون مقاطعة المستخدم.
المطالبة بالمسؤولية عن التحديثات المستقبلية
تسمح طريقة setRequestUpdateOwnership()
للمثبت بالإشارة إلى النظام إلى أنه ينوي أن يكون مسؤولًا عن التحديثات المستقبلية
للتطبيق الذي يثبّته. وتتيح هذه الميزة فرض تحديث الملكية، ما يعني أنّه يُسمح فقط لمالك التحديث بتثبيت التحديثات التلقائية للتطبيق. ويساعد تحديث فرض الملكية على ضمان تلقّي المستخدمين للتحديثات من متجر التطبيقات المتوقّع فقط.
يجب أن يحصل أي مثبّت آخر، بما في ذلك مَن يستفيد من إذن INSTALL_PACKAGES
، على موافقة صريحة من المستخدم لتثبيت التحديث. إذا قرر المستخدم متابعة تحديث من مصدر آخر، ستفقد ملكية التحديث.
تحديث التطبيقات في أوقات أقل إزعاجًا
تحتاج متاجر التطبيقات عادةً إلى تجنُّب تحديث تطبيق قيد الاستخدام، لأن ذلك يؤدي إلى إنهاء عمليات التطبيق قيد التشغيل، ما قد يؤدي إلى مقاطعة ما كان يفعله المستخدم.
بدءًا من نظام التشغيل Android 14، تمنح واجهة برمجة التطبيقات InstallConstraints
API
للمثبّتي التطبيق طريقة لضمان إجراء تحديثات التطبيقات في الوقت المناسب. على سبيل المثال، يمكن لمتجر التطبيقات استدعاء طريقة commitSessionAfterInstallConstraintsAreMet()
للتأكّد من إجراء تحديث فقط عندما لا يتفاعل المستخدم مع التطبيق المعنيّ.
تثبيت التقسيمات الاختيارية بسلاسة
أما مع حِزم APK المجزّأة، فيمكن تقديم ميزات التطبيق في ملفات APK منفصلة،
بدلاً من عرض ميزات التطبيق كحزمة APK متجانسة. وتسمح حِزم APK المقسَّمة لمتاجر التطبيقات بتحسين
عرض مكونات التطبيق المختلفة. على سبيل المثال، قد يتم تحسين متاجر التطبيقات
بناءً على خصائص الجهاز المستهدف. توفّر واجهة برمجة التطبيقات PackageInstaller
إمكانية التقسيمات منذ إطلاقها في المستوى 22 من واجهة برمجة التطبيقات.
في نظام التشغيل Android 14، تسمح طريقة setDontKillApp()
لأداة التثبيت
بالإشارة إلى أنّه يجب عدم إيقاف عمليات التشغيل في التطبيق عند
تثبيت أقسام جديدة. يمكن لمتاجر التطبيقات استخدام هذه الميزة لتثبيت
ميزات جديدة للتطبيق بسلاسة أثناء استخدام المستخدم للتطبيق.
حِزم البيانات الوصفية للتطبيق
بدءًا من نظام التشغيل Android 14، تتيح لك أداة تثبيت حزمة Android تحديد البيانات الوصفية للتطبيقات، مثل ممارسات أمان البيانات، لتضمينها في صفحات متجر التطبيقات، مثل Google Play.
رصد الحالات التي يلتقط فيها المستخدمون لقطات شاشة للجهاز
لإنشاء تجربة موحّدة لرصد لقطات الشاشة، يوفّر Android 14 واجهة برمجة تطبيقات لرصد لقطات الشاشة تحافظ على الخصوصية. تتيح واجهة برمجة التطبيقات هذه للتطبيقات تسجيل عمليات معاودة الاتصال على أساس كل نشاط. يتم استدعاء عمليات معاودة الاتصال هذه ويتم إعلام المستخدم عندما يأخذ المستخدم لقطة شاشة عندما يكون هذا النشاط مرئيًا.
تجربة المستخدم
إجراءات مخصّصة في "قائمة مشاركة البيانات" وترتيب محسَّن
يعدِّل نظام التشغيل Android 14 ورقة مشاركة النظام لإتاحة إجراءات التطبيقات المخصَّصة والمزيد من نتائج المعاينة المفيدة للمستخدمين.
إضافة إجراءات مخصّصة
مع Android 14، يمكن لتطبيقك إضافة إجراءات مخصّصة إلى ورقة مشاركة النظام التي يستدعيها.
![](https://developer.android.com/static/images/training/sharing/sharesheet_custom_actions.png?authuser=8&hl=ar)
تحسين ترتيب أهداف "المشاركة المباشرة"
يستخدم نظام التشغيل Android 14 إشارات أكثر من التطبيقات لتحديد ترتيب أهداف المشاركة المباشرة بهدف تقديم نتائج مفيدة أكثر للمستخدم. لتوفير المؤشر الأكثر فائدة بالنسبة إلى الترتيب، اتّبِع إرشادات تحسين ترتيب استهدافات "المشاركة المباشرة". يمكن لتطبيقات التواصل أيضًا الإبلاغ عن استخدام الاختصارات للرسائل الصادرة والواردة.
![](https://developer.android.com/static/training/sharing/direct-share-targets.png?authuser=8&hl=ar)
دعم الصور المتحركة المدمَجة والمخصَّصة لإظهار ميزة "الظهور التلقائي"
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=true
to 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
,handleOnBackCancelled
in
OnBackPressedCallback
onBackStarted
,onBackProgressed
,onBackCancelled
in
OnBackAnimationCallback
- Use
overrideActivityTransition
instead ofoverridePendingTransition
for 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.
عمليات الإلغاء حسب الشركة المصنّعة للجهاز ذي الشاشة الكبيرة
Per-app overrides enable device manufacturers to change the behavior of apps on large screen devices. For example, the FORCE_RESIZE_APP
override instructs the system to resize the app to fit display dimensions (avoiding size compatibility mode) even if resizeableActivity="false"
is set in the app manifest.
Overrides are intended to improve the user experience on large screens.
New manifest properties enable you to disable some device manufacturer overrides for your app.
عمليات إلغاء مستخدم الشاشة الكبيرة لكل تطبيق
تؤدي عمليات الإلغاء حسب التطبيقات إلى تغيير سلوك التطبيقات على الأجهزة ذات الشاشات الكبيرة. على سبيل المثال، عند إلغاء إعداد الشركة المصنّعة لجهاز OVERRIDE_MIN_ASPECT_RATIO_LARGE
، يتم ضبط نسبة العرض إلى الارتفاع في التطبيق على 16:9 بغض النظر عن إعدادات التطبيق.
يتيح نظام Android 14 QPR1 للمستخدمين تطبيق عمليات الإلغاء لكل تطبيق من خلال قائمة إعدادات جديدة على الأجهزة ذات الشاشات الكبيرة.
مشاركة شاشة التطبيق
App screen sharing enables users to share an app window instead of the entire device screen during screen content recording.
With app screen sharing, the status bar, navigation bar, notifications, and other system UI elements are excluded from the shared display. Only the content of the selected app is shared.
App screen sharing improves productivity and privacy by enabling users to run multiple apps but limit content sharing to a single app.
ميزة "الرد السريع" المستندة إلى نموذج لغوي كبير (LLM) في Gboard على هاتف Pixel 8 Pro
On Pixel 8 Pro devices with the December Feature Drop, developers can try out higher-quality smart replies in Gboard powered by on-device Large Language Models (LLMs) running on Google Tensor.
This feature is available as a limited preview for US English in WhatsApp, Line, and KakaoTalk. It requires using a Pixel 8 Pro device with Gboard as your keyboard.
To try it out, first enable the feature in Settings > Developer Options > AiCore Settings > Enable Aicore Persistent.
Next, open a conversation in a supported app to see LLM-powered Smart Reply in Gboard's suggestion strip in response to incoming messages.
الرسومات
المسارات القابلة للاستعلام والدمج
واجهة برمجة التطبيقات Path
في Android هي آلية فعّالة ومرنة لإنشاء الرسومات المتّجهة وعرضها، مع إمكانية رسم مسار أو تعبئته، وإنشاء مسار من القطاعات الخطية أو المنحنيات التربيعية أو التكعيبية، أو تنفيذ عمليات منطقية للحصول على أشكال أكثر تعقيدًا، أو تنفيذ جميع هذه الإجراءات في الوقت نفسه. يتمثل أحد القيود في إمكانية اكتشاف ما هو موجود بالفعل في كائن Path (مسار)، حيث لا تكون العناصر الداخلية للكائن معتمة للمُتصِلين بعد الإنشاء.
لإنشاء Path
، يمكنك استدعاء طرق مثل
moveTo()
وlineTo()
وcubicTo()
لإضافة أقسام المسار. ولكن لم تكن هناك طريقة تسأل عن ماهية المقاطع
في هذا المسار، لذا يجب عليك الاحتفاظ بهذه المعلومات في
وقت الإنشاء.
بدءًا من نظام التشغيل Android 14، يمكنك الاستعلام عن المسارات لمعرفة مضمونها.
أولاً، يجب الحصول على عنصر PathIterator
باستخدام
Path.getPathIterator
API:
Kotlin
val path = Path().apply { moveTo(1.0f, 1.0f) lineTo(2.0f, 2.0f) close() } val pathIterator = path.pathIterator
Java
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}") }
Java
while (pathIterator.hasNext()) { PathIterator.Segment segment = pathIterator.next(); Log.i(LOG_TAG, "segment: " + segment.getVerb() + ", " + segment.getPoints()); }
لدى PathIterator
أيضًا إصدار غير مخصّص من next()
يمكنك من خلاله تمرير
مخزن احتياطي للاحتفاظ ببيانات النقاط.
إحدى حالات الاستخدام المهمة للاستعلام عن بيانات Path
هي الاستيفاء. على سبيل المثال، قد ترغب في تحريك (أو تحويل) بين مسارين مختلفين. ولتبسيط حالة الاستخدام هذه بشكل أكبر، يتضمّن Android 14 أيضًا طريقة
interpolate()
في Path
. على افتراض أن المسارين لهما نفس البنية الداخلية، تقوم طريقة interpolate()
بإنشاء Path
جديد بهذه النتيجة المضافة. يعرض هذا المثال مسارًا يكون شكله في المنتصف (استيفاء خطيًا لرقم 5.) بين path
وotherPath
:
Kotlin
val interpolatedResult = Path() if (path.isInterpolatable(otherPath)) { path.interpolate(otherPath, .5f, interpolatedResult) }
Java
Path interpolatedResult = new Path(); if (path.isInterpolatable(otherPath)) { path.interpolate(otherPath, 0.5F, interpolatedResult); }
توفّر مكتبة مسار الرسومات في Jetpack واجهات برمجة تطبيقات مشابهة للإصدارات السابقة من نظام التشغيل Android أيضًا.
شبكات مخصّصة مع أدوات تظليل الأجزاء برأسي وأجزاء
لطالما دعم نظام Android لرسم شبكات المثلّثات ذات التظليل المخصّص، غير أنّ تنسيق شبكة الإدخال كان يقتصر على بعض مجموعات السمات المحدّدة مسبقًا. يتيح نظام التشغيل Android 14 استخدام الشبكات المخصّصة التي يمكن تعريفها على أنّها مثلثات أو أشرطة مثلثية، ويمكن فهرستها اختياريًا. يتم تحديد هذه الشبكات باستخدام سمات مخصّصة، وخطوات في أعلى الرأس، ومتفاوتة، وأدوات تظليل الأجزاء الرأسية والأجزاء المكتوبة بلغة AGSL.
وتحدد أداة تظليل الأجزاء التباينات، مثل الموضع واللون، بينما يمكن لأداة تظليل الأجزاء تحديد لون وحدة البكسل بشكل اختياري، وذلك عادةً باستخدام الاختلافات التي يتم إنشاؤها بواسطة أداة تظليل الرأس. إذا تم توفير اللون من خلال أداة تظليل الأجزاء، يتم مزجه مع لون Paint
الحالي باستخدام وضع المزج الذي يتم اختياره عند رسم الشبكة المتداخلة. يمكن إدخال الأزياء الموحّدة إلى الجزء وظلال الرأس للحصول على مزيد من المرونة.
عارض المخزن المؤقت للأجهزة للوحة الرسم
للمساعدة في استخدام واجهة برمجة التطبيقات Canvas
في نظام التشغيل Android للرسم باستخدام
تسريع الأجهزة في HardwareBuffer
، يطرح Android 14
HardwareBufferRenderer
. تفيدك واجهة برمجة التطبيقات هذه بشكل خاص عندما تتضمّن حالة الاستخدام الاتصال بمكوِّن النظام من خلال SurfaceControl
للرسم في وقت استجابة سريع.