[[["易于理解","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,["# 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."]]