AppCompatDelegate

public abstract class AppCompatDelegate
extends Object

java.lang.Object
   ↳ androidx.appcompat.app.AppCompatDelegate


This class represents a delegate which you can use to extend AppCompat's support to any Activity.

When using an AppCompatDelegate, you should call the following methods instead of the Activity method of the same name:

The following methods should be called from the Activity method of the same name:

An Activity can only be linked with one AppCompatDelegate instance, therefore the instance returned from create(Activity, AppCompatCallback) should be retained until the Activity is destroyed.

Summary

Constants

int FEATURE_ACTION_MODE_OVERLAY

Flag for specifying the behavior of action modes when an Action Bar is not present.

int FEATURE_SUPPORT_ACTION_BAR

Flag for enabling the support Action Bar.

int FEATURE_SUPPORT_ACTION_BAR_OVERLAY

Flag for requesting an support Action Bar that overlays window content.

int MODE_NIGHT_AUTO

This constant is deprecated. Use MODE_NIGHT_AUTO_TIME instead

int MODE_NIGHT_AUTO_BATTERY

Night mode which uses a dark mode when the system's 'Battery Saver' feature is enabled, otherwise it uses a 'light mode'.

int MODE_NIGHT_AUTO_TIME

This constant is deprecated. Automatic switching of dark/light based on the current time is deprecated. Considering using an explicit setting, or MODE_NIGHT_AUTO_BATTERY.

int MODE_NIGHT_FOLLOW_SYSTEM

Mode which uses the system's night mode setting to determine if it is night or not.

int MODE_NIGHT_NO

Night mode which uses always uses a light mode, enabling notnight qualified resources regardless of the time.

int MODE_NIGHT_UNSPECIFIED

An unspecified mode for night mode.

int MODE_NIGHT_YES

Night mode which uses always uses a dark mode, enabling night qualified resources regardless of the time.

Public methods

abstract void addContentView(View v, ViewGroup.LayoutParams lp)

Should be called instead of Activity.addContentView(android.view.View, android.view.ViewGroup.LayoutParams)}

abstract boolean applyDayNight()

Applies the currently selected night mode to this delegate's host component.

void attachBaseContext(Context context)

This method is deprecated. use attachBaseContext2(Context) instead.

Context attachBaseContext2(Context context)

Should be called from Activity.attachBaseContext(Context).

static AppCompatDelegate create(Activity activity, AppCompatCallback callback)

Create an AppCompatDelegate to use with activity.

static AppCompatDelegate create(Dialog dialog, AppCompatCallback callback)

Create an AppCompatDelegate to use with dialog.

static AppCompatDelegate create(Context context, Activity activity, AppCompatCallback callback)

Create an AppCompatDelegate to use with a context and hosted by an Activity.

static AppCompatDelegate create(Context context, Window window, AppCompatCallback callback)

Create an AppCompatDelegate to use with a context and a window.

abstract View createView(View parent, String name, Context con