ProtectionLayout

A layout drawing views under system bars, called Protections, to ensure enough contrast between the system bars (such as status bar and navigation bar) and the app content.

This layout is meant to be used in edge-to-edge scenarios. The Protections are set using the setProtections method or directly in the view constructor.

If this view will be attached to a hierarchy owned by a Window, it is strongly recommended to call enableEdgeToEdge to make sure the view can reach the edges of the window and the framework color views are gone.

Constructors

Link copied to clipboard
constructor(@NonNull context: @NonNull Context)
constructor(@NonNull context: @NonNull Context, @Nullable attrs: @Nullable AttributeSet)
constructor(@NonNull context: @NonNull Context, @Nullable attrs: @Nullable AttributeSet, @AttrRes defStyleAttr: Int)
constructor(@NonNull context: @NonNull Context, @Nullable attrs: @Nullable AttributeSet, @AttrRes defStyleAttr: Int, @StyleRes defStyleRes: Int)
constructor(@NonNull context: @NonNull Context, @NonNull protections: @NonNull List<Protection>)
Constructs a view which draws protections contained in the specified list.

Functions

Link copied to clipboard
open fun addView(@Nullable child: @Nullable View, index: Int, params: @Nullable ViewGroup.LayoutParams)
Link copied to clipboard
open fun setProtections(@NonNull protections: @NonNull List<Protection>)
Replaces existing Protections with the given ones.