-
public class ViewUtils
Utils class for custom views.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
ViewUtils.OnApplyWindowInsetsListener
Wrapper around tds.androidx.core.view.OnApplyWindowInsetsListener which also passesthe initial padding set on the view. Used with doOnApplyWindowInsets.
public class
ViewUtils.RelativePadding
Simple data object to store the initial padding for a view.
-
Method Summary
Modifier and Type Method Description static PorterDuff.Mode
parseTintMode(int value, PorterDuff.Mode defaultMode)
static boolean
isLayoutRtl(View view)
static float
dpToPx(@NonNull() Context context, @Dimension(unit = Dimension.DP) int dp)
static void
requestFocusAndShowKeyboard(@NonNull() View view)
static void
doOnApplyWindowInsets(@NonNull() View view, @Nullable() AttributeSet attrs, int defStyleAttr, int defStyleRes)
Wrapper around tds.androidx.core.view.OnApplyWindowInsetsListener that canautomatically apply inset padding based on view attributes. static void
doOnApplyWindowInsets(@NonNull() View view, @Nullable() AttributeSet attrs, int defStyleAttr, int defStyleRes, @Nullable() ViewUtils.OnApplyWindowInsetsListener listener)
Wrapper around tds.androidx.core.view.OnApplyWindowInsetsListener that canautomatically apply inset padding based on view attributes. static void
doOnApplyWindowInsets(@NonNull() View view, @NonNull() ViewUtils.OnApplyWindowInsetsListener listener)
Wrapper around tds.androidx.core.view.OnApplyWindowInsetsListener that records theinitial padding of the view and requests that insets are applied when attached. static void
requestApplyInsetsWhenAttached(@NonNull() View view)
Requests that insets should be applied to this view once it is attached. static float
getParentAbsoluteElevation(@NonNull() View view)
Returns the absolute elevation of the parent of the provided {@code view}
, or in other words,the sum of the elevations of all ancestors of the{@code view}
.static ViewOverlayImpl
getOverlay(@Nullable() View view)
Backward-compatible getOverlay. static ViewGroup
getContentView(@Nullable() View view)
Returns the content view that is the parent of the provided view. static ViewOverlayImpl
getContentViewOverlay(@NonNull() View view)
Returns the content view overlay that can be used to add drawables on top of all other views. static void
addOnGlobalLayoutListener(@Nullable() View view, @NonNull() ViewTreeObserver.OnGlobalLayoutListener victim)
static void
removeOnGlobalLayoutListener(@Nullable() View view, @NonNull() ViewTreeObserver.OnGlobalLayoutListener victim)
static void
removeOnGlobalLayoutListener(@NonNull() ViewTreeObserver viewTreeObserver, @NonNull() ViewTreeObserver.OnGlobalLayoutListener victim)
-
-
Method Detail
-
parseTintMode
static PorterDuff.Mode parseTintMode(int value, PorterDuff.Mode defaultMode)
-
isLayoutRtl
static boolean isLayoutRtl(View view)
-
dpToPx
static float dpToPx(@NonNull() Context context, @Dimension(unit = Dimension.DP) int dp)
-
requestFocusAndShowKeyboard
static void requestFocusAndShowKeyboard(@NonNull() View view)
-
doOnApplyWindowInsets
static void doOnApplyWindowInsets(@NonNull() View view, @Nullable() AttributeSet attrs, int defStyleAttr, int defStyleRes)
Wrapper around tds.androidx.core.view.OnApplyWindowInsetsListener that canautomatically apply inset padding based on view attributes.
-
doOnApplyWindowInsets
static void doOnApplyWindowInsets(@NonNull() View view, @Nullable() AttributeSet attrs, int defStyleAttr, int defStyleRes, @Nullable() ViewUtils.OnApplyWindowInsetsListener listener)
Wrapper around tds.androidx.core.view.OnApplyWindowInsetsListener that canautomatically apply inset padding based on view attributes.
-
doOnApplyWindowInsets
static void doOnApplyWindowInsets(@NonNull() View view, @NonNull() ViewUtils.OnApplyWindowInsetsListener listener)
Wrapper around tds.androidx.core.view.OnApplyWindowInsetsListener that records theinitial padding of the view and requests that insets are applied when attached.
-
requestApplyInsetsWhenAttached
static void requestApplyInsetsWhenAttached(@NonNull() View view)
Requests that insets should be applied to this view once it is attached.
-
getParentAbsoluteElevation
static float getParentAbsoluteElevation(@NonNull() View view)
Returns the absolute elevation of the parent of the provided
{@code view}
, or in other words,the sum of the elevations of all ancestors of the{@code view}
.
-
getOverlay
@Nullable() static ViewOverlayImpl getOverlay(@Nullable() View view)
Backward-compatible getOverlay. TODO(b/144937975): Remove and use the officialversion from androidx when it's available.
-
getContentView
@Nullable() static ViewGroup getContentView(@Nullable() View view)
Returns the content view that is the parent of the provided view.
-
getContentViewOverlay
@Nullable() static ViewOverlayImpl getContentViewOverlay(@NonNull() View view)
Returns the content view overlay that can be used to add drawables on top of all other views.
-
addOnGlobalLayoutListener
static void addOnGlobalLayoutListener(@Nullable() View view, @NonNull() ViewTreeObserver.OnGlobalLayoutListener victim)
-
removeOnGlobalLayoutListener
static void removeOnGlobalLayoutListener(@Nullable() View view, @NonNull() ViewTreeObserver.OnGlobalLayoutListener victim)
-
removeOnGlobalLayoutListener
static void removeOnGlobalLayoutListener(@NonNull() ViewTreeObserver viewTreeObserver, @NonNull() ViewTreeObserver.OnGlobalLayoutListener victim)
-
-
-
-