AndroidBrowserOptionsBuilder¶
Fluent builder for AndroidBrowserOptions. Options not configured use the system or browser default.
Kodster.InAppWebBrowser.Android.AndroidBrowserOptionsBuilder
Overview¶
Each With* method returns the same builder instance for fluent chaining. Call Build() to create the final AndroidBrowserOptions object.
Each With* call is feature-gated against the detected androidx.browser version. If the feature is unsupported, the call is ignored and a warning is logged. See AndroidX Browser Version Requirements for the minimum version per feature.
Example¶
#if UNITY_ANDROID
var options = new AndroidBrowserOptionsBuilder()
.WithColorScheme(AndroidColorScheme.Dark)
.WithTitleShown(true)
.WithUrlHidingEnabled(true)
.Build();
AndroidBrowser.Open("https://example.com", options);
#endif
Methods¶
WithTitleShown¶
Sets whether the page title is shown in the toolbar.
Parameters
titleShown(bool):trueto show the page title; otherwisefalse.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.2.0 or higher.
WithShareButtonState¶
Sets the visibility of the share button.
Parameters
shareButtonState(ShareButtonState): The desired share button state.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.3.0 or higher.
WithUrlHidingEnabled¶
Sets whether the URL bar is hidden when scrolling down the page.
Parameters
urlHidingEnabled(bool):trueto hide the URL bar.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.3.0 or higher.
WithBackgroundInteractionEnabled¶
public AndroidBrowserOptionsBuilder WithBackgroundInteractionEnabled(
bool backgroundInteractionEnabled
)
Sets whether the user can interact with the app behind the browser while it is displayed in partial-screen mode.
Parameters
backgroundInteractionEnabled(bool):trueto allow background interaction.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.7.0 or higher.
WithBookmarksButtonEnabled¶
Sets whether the bookmark button is shown in the overflow menu.
Parameters
bookmarksButtonEnabled(bool):trueto show the bookmarks button.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.7.0 or higher.
WithDownloadButtonEnabled¶
Sets whether the download button is shown in the overflow menu.
Parameters
downloadButtonEnabled(bool):trueto show the download button.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.7.0 or higher.
WithEphemeralBrowsingEnabled¶
Sets whether the browser clears cookies and browsing data when closed.
Parameters
ephemeralBrowsingEnabled(bool):trueto enable ephemeral browsing.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.9.0 or higher.
WithColorScheme¶
Sets the color scheme used for the browser UI.
Parameters
androidColorScheme(AndroidColorScheme): The desired color scheme.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.2.0 or higher.
WithLightColorSchemeOptions¶
public AndroidBrowserOptionsBuilder WithLightColorSchemeOptions(
ColorSchemeOptions lightColorSchemeOptions
)
Sets the color customization applied when the browser is in light mode.
Parameters
lightColorSchemeOptions(ColorSchemeOptions): Light mode color options.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.2.0 or higher.
WithDarkColorSchemeOptions¶
public AndroidBrowserOptionsBuilder WithDarkColorSchemeOptions(
ColorSchemeOptions darkColorSchemeOptions
)
Sets the color customization applied when the browser is in dark mode.
Parameters
darkColorSchemeOptions(ColorSchemeOptions): Dark mode color options.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.2.0 or higher.
WithDefaultColorSchemeOptions¶
public AndroidBrowserOptionsBuilder WithDefaultColorSchemeOptions(
ColorSchemeOptions defaultColorSchemeOptions
)
Sets the fallback color customization used when no mode-specific options are matched.
Parameters
defaultColorSchemeOptions(ColorSchemeOptions): Fallback color options.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.3.0 or higher.
WithInitialHeightPercent¶
Sets the initial height of the browser as a percentage of the screen height, in bottom-sheet mode. Clamped to 50–100.
Parameters
initialHeightPercent(int): Initial height as a percentage of the screen height.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.5.0 or higher.
WithInitialWidthPercent¶
Sets the initial width of the browser as a percentage of the screen width, in side-sheet mode. Clamped to 33–100.
Parameters
initialWidthPercent(int): Initial width as a percentage of the screen width.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.8.0 or higher.
WithHeightResizeBehavior¶
public AndroidBrowserOptionsBuilder WithHeightResizeBehavior(
HeightResizeBehavior heightResizeBehavior
)
Sets whether the user can resize the browser height in bottom-sheet mode.
Parameters
heightResizeBehavior(HeightResizeBehavior): The desired resize behavior.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.5.0 or higher.
WithToolbarCornerRadiusDp¶
Sets the corner radius of the toolbar, in density-independent pixels (dp). Clamped to 1–16.
Parameters
toolbarCornerRadiusDp(int): Corner radius in dp.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.5.0 or higher.
WithOpenTransition¶
public AndroidBrowserOptionsBuilder WithOpenTransition(
AndroidBrowserTransition openAndroidBrowserTransition
)
Sets the transition played when the browser opens.
Parameters
openAndroidBrowserTransition(AndroidBrowserTransition): Transition to play on open.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.2.0 or higher.
WithCloseTransition¶
public AndroidBrowserOptionsBuilder WithCloseTransition(
AndroidBrowserTransition closeAndroidBrowserTransition
)
Sets the transition played when the browser closes.
Parameters
closeAndroidBrowserTransition(AndroidBrowserTransition): Transition to play on close.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.2.0 or higher.
WithAppSpecificHistoryEnabled¶
Sets whether to opt in to App-specific history, available from Chrome 126 on Android 14+. When enabled, links opened in the browser are recorded in Chrome's history alongside the app's name, allowing users to find and resume previously visited pages.
Parameters
appSpecificHistoryEnabled(bool):trueto enable app-specific history.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.7.0 or higher.
WithOpenInExternalHandlerEnabled¶
public AndroidBrowserOptionsBuilder WithOpenInExternalHandlerEnabled(
bool openInExternalHandlerEnabled
)
Sets whether URLs that match an external app's default handler are forwarded to that app instead of being opened inside the browser.
Parameters
openInExternalHandlerEnabled(bool):trueto route matching URLs to external apps.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.7.0 or higher.
WithSideSheetBreakpointDp¶
Sets the screen width, in dp, at which the browser switches to side-sheet mode.
Parameters
sideSheetBreakpointDp(int): Breakpoint width in dp.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.8.0 or higher.
WithSideSheetDecoration¶
public AndroidBrowserOptionsBuilder WithSideSheetDecoration(
SideSheetDecoration sideSheetDecoration
)
Sets the decoration style applied to the side-sheet.
Parameters
sideSheetDecoration(SideSheetDecoration): The desired decoration style.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.8.0 or higher.
WithSideSheetMaximizationEnabled¶
public AndroidBrowserOptionsBuilder WithSideSheetMaximizationEnabled(
bool sideSheetMaximizationEnabled
)
Sets whether the side-sheet can be maximized to fill the screen.
Parameters
sideSheetMaximizationEnabled(bool):trueto allow maximization.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.8.0 or higher.
WithSideSheetPosition¶
Sets the position of the side-sheet on the screen.
Parameters
sideSheetPosition(SideSheetPosition): The desired side-sheet position.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.8.0 or higher.
WithSideSheetRoundedCornersPosition¶
public AndroidBrowserOptionsBuilder WithSideSheetRoundedCornersPosition(
SideSheetRoundedCornersPosition sheetRoundedCornersPosition
)
Sets which corners of the side-sheet have rounded styling applied.
Parameters
sheetRoundedCornersPosition(SideSheetRoundedCornersPosition): Rounded corner position rule.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.8.0 or higher.
WithCloseButtonPosition¶
public AndroidBrowserOptionsBuilder WithCloseButtonPosition(
CloseButtonPosition closeButtonPosition
)
Sets the position of the close button in the toolbar.
Parameters
closeButtonPosition(CloseButtonPosition): The desired close button position.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.5.0 or higher.
WithCloseButtonIcon¶
Sets the icon style used for the close button.
Parameters
closeButtonIcon(CloseButtonIcon): The desired close button icon.
Returns
- The current
AndroidBrowserOptionsBuilderinstance.
Remarks
- Requires
androidx.browserversion 1.2.0 or higher.
Build¶
Builds and returns an AndroidBrowserOptions instance from the current configuration. Only options explicitly set via the With* methods are included; unset options remain null.
Returns
- A new
AndroidBrowserOptionsinstance reflecting the builder's current state.