Android 12 introduces a new dual pane design, with a static L0 menu on the left and a content pane on the right. This feature introduces many new customization options. This article details those features and explains how you can customize your own preferences.
Revert to single pane
By default, CarSettings now displays the dual pane view when the application window is greater than or equal to 1400dp in width and the single pane view otherwise. To customize this for a specific device, use a Runtime Resource Overlay (RRO) to target the necessary configuration values:
||Specifies the starting fragment for the homepage. In dual pane, this is used for the initial fragment in the content pane. In single-pane, this should be the homepage fragment.|
Because different CarSettings activities can have a customized IA, a header key mapping
is provided to simplify customizations. In
AndroidManifest.xml, every activity
that supports dual pane has a
TOP_LEVEL_HEADER_KEY specified in its metadata.
This value points to a key specified in
res/values/header_keys.xml, which is
mapped to the preference key of the top-level menu item that the starting fragment falls under.
Therefore, if the starting fragment of an activity is changed or the IA is rearranged such
that a particular fragment falls under a different top-level preference, the relevant mapping(s)
header_keys.xml file can be updated to specify the correct value.
Customize activity layout
The layout for
BaseCarSettingsActivity is located in
res/layout/car_setting_activity and in these sections:
||Top-level menu fragment shown in dual pane configurations. Width of this section is
||Vertical line that splits the two panes and whose width you can customize with
||Wrapper layout for the content pane (or the main pane in a singlepane configuration). A chassis baselayout (with toolbar) is wrapped around this view.|
||Custom implementation of
||Main content container. Content fragments use this as the target layout.|
||UX-restricted blocking view to be shown on instances of
Figure 1. Dual pane layout
Top-level preferences are custom CarUiPreferences with a slightly modified layout to change the preference height and background shape. There are many different ways to customize the look of these preferences:
||Overlay the entire preference layout.|
||Minimum height of the top-level preference. Depending on content (for example, a subtitle is present), preferences may be taller than this value.|
||Radius of the corner rounding.|
||Background of the top-level preferences when not currently highlighted.|
||Background of top-level preferences when highlighted.|
Figure 2 illustrates how the top-level icons now consist of a vector icon inside a colored background shape. This shape is currently configured to support either an oval a rectangular shape. By default, shape is set to oval.
To change the default, modify the value in
(where 0 is rectangle and 1 is oval). The icons are created by insetting the foreground icon by
top_level_foreground_icon_inset from the background shape. Each top-level icon has
a foreground color specified in
res/values/colors.xml and a background color
specified in the
To create a customized appearance, you can override all color values.
Figure 2. Top-level preference components
Icons for injected preferences that fall into the categories specified by
config_top_level_injection_categories are also treated as top-level icons.
The provided icons are inset by the same value and into the same shape as specified for
all other top-level icons (see above). However, the background is determined by looking
at the following attributes in this order:
com.android.settings.bg.argbMeta data from the injecting application.
com.android.settings.bg.hintMeta data from the injecting application.
To ignore the injecting application data and always use the default background, set