اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release بدلاً من aosp-main لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
توضّح هذه الصفحة عملية تخصيصCarUiRecyclerView وشريط التمرير.
المتطلّبات الأساسية
تفترض هذه الصفحة معرفة حزمة APK المستهدَفة لتطبيق "تداخل الموارد أثناء التشغيل" (RRO). لمزيد من المعلومات، يُرجى الاطّلاع على مقالة تخصيص التطبيقات.
لمحة عن CarUiRecyclerView
عند ضبط car_ui_scrollbar_enable على false في bools.xml،
لا يضخّم CarUiRecyclerView شريط التمرير. ومع ذلك، يتم تضخيم العلامة
androidx.recyclerview فقط باستخدام الأنماط القابلة للتخصيص كما هو موضّح أدناه.
عند ضبط car_ui_scrollbar_enable على true،
يضخّم CarUiRecyclerView الحاوية التي تم تثبيت شريط التمرير فيها
داخلها. في وقت لاحق، تتم أيضًا إضافة androidx.recyclerview داخل الحاوية
نفسها.
يمكن لـ CarUiRecyclerView استخدام أي محوِّل لعرض البيانات. ولكن يُنصح باستخدام CarUiListItemAdapter حيث تحدِّد مكتبة الشاسيه CarUiListItemAdapter تنسيق listItems، وبالتالي يمكن لمصنّعي المعدّات الأصلية تخصيصها. يتم تحديد تخصيص ListItems
في خيارات تخصيص
CarUiListItem.
يتم استخدام car_ui_scrollbar_margin تلقائيًا كعرض عرض شريط التمرير.
تتم أيضًا إضافة هذا الهامش كandroid:endMargin من CarUiRecyclerView حتى
يكون هناك هامش متساوٍ في بداية البيانات ونهايتها. إذا استخدم المطوِّر
enableDivider=true، يمكن لمصنّع المعدّات الأصلية التحكّم في كيفية ظهور الفواصل.
في ما يلي السمات التي يمكن تعديلها في CarUiRecyclerView:
يتم تحديد ملف التنسيق الخاص بشريط التمرير CarUiRV في
car_ui_recyclerview_scrollbar.xml. في المجمل، يتم تحديد هذه المشاهدات الأربعة
ضمن العرض:
المشاهدات
Car_ui_scrollbar_page_up
تحدِّد هذه السمة زرّ "لأعلى" في شريط التمرير.
Car_ui_scrollbar_page_down
تحدِّد زر الانتقال للأسفل في شريط التمرير.
Car_ui_scrollbar_thumb
يتم احتساب الارتفاع ديناميكيًا استنادًا إلى عدد عناصر القائمة في
Recycler View (RV).
Car_ui_scrollbar_track
الارتفاع الإجمالي الذي يحدّد الحدود التي سيتحرك فيها الإصبع
على المصنّعين الأصليّين للأجهزة وضع ملف التنسيق هذا فوق ملف التنسيق لتخصيص شريط التمرير. يجب وضع عرض المقطع الصوتي
بعناية لأنّ ذلك سيحدّد الحدود التي سيتحرك فيها إصبع الإبهام.
يتم احتساب ارتفاع الصورة المصغّرة ديناميكيًا استنادًا إلى عناصر القائمة في "عرض الفيديو" الافتراضي والارتفاع
لحاملي الشاشة.
يتم تضمين هذا التنسيق في حاوية CarUiRVcar_ui_recycler_view.xmlفقط إذا كان car_ui_scrollbar_enabletrue.
في ما يلي السمات الأخرى التي يمكن تعديلها في شريط التمرير:
إذا كان يجب تعديل عنصر قابل للرسم من النوع "أعلى" أو "أسفل" أو "زر الإبهام"، يجب أيضًا وضعه فوق العنصر الأصلي.
إذا تم استخدام أي موارد جديدة في حزمة RRO غير متوفّرة حاليًا، يجب تحديد
هذه الموارد أيضًا في حزمة APK لتطبيق RRO التي تنشئها.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 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"]],["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Customize CarUiRecyclerView\n\nThis page describes the process of customizing`CarUiRecyclerView` and the scroll\nbar.\n\nPrerequisites\n-------------\n\nThis page presumes knowledge of a runtime resource overlay (RRO) target APK. To learn\nmore, see [Customize apps](/docs/automotive/hmi/car_ui/customize).\n\nAbout CarUiRecyclerView\n-----------------------\n\nWhen `car_ui_scrollbar_enable` is set to `false` in `bools.xml`,\n`CarUiRecyclerView` doesn't inflate the scrollbar. That said, only the\n`androidx.recyclerview` is inflated with customizable styles as defined below.\nWhen `car_ui_scrollbar_enable` is set to `true`,\n`CarUiRecyclerView` inflates the container with the scrollbar installed\nwithin it. Later `androidx.recyclerview` is also added within the same\ncontainer.\n\n`CarUiRecyclerView` can take any adapter to display the data. But the\nrecommendation is to use `CarUiListItemAdapter` where the chassis lib defines the\nlayout for listItems and hence can be customized by OEMs. The customization for ListItems\nare defined in [Customization\noptions for CarUiListItem](/docs/automotive/hmi/car_ui/caruilistitem).\n\nBy default, `car_ui_scrollbar_margin` is used as the width of the scrollbar view.\nThis margin is also added as `android:endMargin` of the CarUiRecyclerView so\nthere is equal margin at the start and end of the data. If the developer had used\n`enableDivider=true` then the OEM can control how the dividers should appear.\nDimensions that can be adjusted for `CarUiRecyclerView` are: \n\n```scdoc\n \u003cdimen name=\"car_ui_recyclerview_divider_height\"\u003e0dp\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_recyclerview_divider_start_margin\"\u003e0dp\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_recyclerview_divider_end_margin\"\u003e0dp\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_recyclerview_divider_top_margin\"\u003e0dp\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_recyclerview_divider_bottom_margin\"\u003e0dp\u003c/dimen\u003e\n```\n\nScrollbar\n---------\n\n| **Note:** You can only customize scrollbar layout in releases of Android 10 and higher.\n\nThe layout file for `CarUiRV` scrollbar is defined in\n`car_ui_recyclerview_scrollbar.xml`. In total, these four views are\ndefined within the view:\n\n| Views ||\n|------------------------------|---------------------------------------------------------------------------------------------------|\n| `Car_ui_scrollbar_page_up` | Defines the up button of the scrollbar. |\n| `Car_ui_scrollbar_page_down` | defines the down button of the scrollbar. |\n| `Car_ui_scrollbar_thumb` | Height is calculated dynamically depending on the number of list items in the Recycler View (RV). |\n| `Car_ui_scrollbar_track` | Total height that defines the bounds in which the thumb will move. |\n\nOEMs should overlay this layout file to customize the scrollbar. Track view should be\nplaced carefully as that would define the bounds in which the thumb will move.\nThumb height is calculated dynamically based on the list items in the RV and the height\nof the viewholders.\n\nThis layout is included in the `CarUiRV` container\n`car_ui_recycler_view.xml` **only** if `car_ui_scrollbar_enable`\nis `true`.\n\nOther dimensions that can be adjusted for scrollbar are: \n\n```carbon\n \u003cdimen name=\"car_ui_scrollbar_container_width\"\u003e@dimen/car_ui_margin\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_scrollbar_button_size\"\u003e@dimen/car_ui_touch_target_width\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_scrollbar_thumb_width\"\u003e7dp\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_scrollbar_separator_margin\"\u003e16dp\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_scrollbar_margin\"\u003e@dimen/car_ui_margin\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_scrollbar_thumb_radius\"\u003e100dp\u003c/dimen\u003e\n\n \u003citem name=\"car_ui_button_disabled_alpha\" format=\"float\" type=\"dimen\"\u003e0.2\u003c/item\u003e\n \u003citem name=\"car_ui_scrollbar_milliseconds_per_inch\" format=\"float\" type=\"dimen\"\u003e150.0\u003c/item\u003e\n \u003citem name=\"car_ui_scrollbar_deceleration_times_divisor\" format=\"float\" type=\"dimen\"\u003e0.45\u003c/item\u003e\n \u003citem name=\"car_ui_scrollbar_decelerate_interpolator_factor\" format=\"float\" type=\"dimen\"\u003e1.8\u003c/item\u003e\n\n \u003cdimen name=\"car_ui_scrollbar_padding_start\"\u003e0dp\u003c/dimen\u003e\n \u003cdimen name=\"car_ui_scrollbar_padding_end\"\u003e0dp\u003c/dimen\u003e\n```\n\nExample\n-------\n\nFor example, to bring both the Up and Down arrow together at the bottom of the screen:\n\n1. Overlay `car_ui_recyclerview_scrollbar.xml`: \n\n ```transact-sql\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003cRelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:layout_width=\"@dimen/car_ui_margin\"\n android:layout_height=\"match_parent\"\n android:id=\"@+id/car_ui_scroll_bar\"\u003e\n\n \u003c!-- View height is dynamically calculated during layout. --\u003e\n \u003cView\n android:id=\"@+id/car_ui_scrollbar_thumb\"\n android:layout_width=\"7dp\"\n android:layout_height=\"20dp\"\n android:layout_alignParentTop=\"true\"\n android:layout_centerHorizontal=\"true\"\n android:background=\"@drawable/car_ui_recyclerview_scrollbar_thumb\"/\u003e\n\n \u003cView\n android:id=\"@+id/car_ui_scrollbar_track\"\n android:layout_width=\"10dp\"\n android:layout_height=\"match_parent\"\n android:layout_marginTop=\"10dp\"\n android:layout_centerHorizontal=\"true\"\n android:layout_above=\"@+id/car_ui_scrollbar_page_up\"/\u003e\n\n \u003cImageView\n android:id=\"@+id/car_ui_scrollbar_page_up\"\n android:layout_width=\"76dp\"\n android:layout_height=\"76dp\"\n android:focusable=\"false\"\n android:hapticFeedbackEnabled=\"false\"\n android:src=\"@drawable/car_ui_recyclerview_ic_up\"\n android:scaleType=\"centerInside\"\n android:layout_centerHorizontal=\"true\"\n android:layout_above=\"@+id/car_ui_scrollbar_page_down\"/\u003e\n\n \u003cImageView\n android:id=\"@+id/car_ui_scrollbar_page_down\"\n android:layout_width=\"76dp\"\n android:layout_height=\"76dp\"\n android:focusable=\"false\"\n android:hapticFeedbackEnabled=\"false\"\n android:src=\"@drawable/car_ui_recyclerview_ic_down\"\n android:scaleType=\"centerInside\"\n android:layout_centerHorizontal=\"true\"\n android:layout_alignParentBottom=\"true\"/\u003e\n \u003c/RelativeLayout\u003e\n ```\n2. To define the resources to be overlaid by the RRO, add `Overlays.xml`: \n\n ```transact-sql\n \u003coverlay\u003e\n \u003citem target=\"id/car_ui_scroll_bar\" value=\"@id/car_ui_scroll_bar\"/\u003e\n \u003citem target=\"id/car_ui_scrollbar_thumb\" value=\"@id/car_ui_scrollbar_thumb\"/\u003e\n \u003citem target=\"id/car_ui_scrollbar_track\" value=\"@id/car_ui_scrollbar_track\"/\u003e\n \u003citem target=\"id/car_ui_scrollbar_page_up\" value=\"@id/car_ui_scrollbar_page_up\"/\u003e\n \u003citem target=\"id/car_ui_scrollbar_page_down\" value=\"@id/car_ui_scrollbar_page_down\"/\u003e\n \u003citem target=\"layout/car_ui_recyclerview_scrollbar\" value=\"@layout/car_ui_recyclerview_scrollbar\"/\u003e\n \u003c/overlay\u003e\n ```\n3. If an Up, Down, or thumb drawable must be updated, they should also be overlaid.\n4. If any new resources are used in the RRO package that do not already exist, then these resources should also be defined in the RRO APK you create."]]