Object ViewUtils

  • All Implemented Interfaces:

    
    public class ViewUtils
    
                        
    • Constructor Detail

    • Method Detail

      • addTo

         final <T extends View> T addTo(T $self, ViewGroup group, Function1<T, Unit> block)

        Shorthand extension function to add a View into a ViewGroup, and then run a scoped function

        Parameters:
        group - ViewGroup to add this View into
        block - A scoped function, with the View as its receiver
        Returns:

        The View

      • addTo

         final <T extends View> T addTo(T $self, ViewGroup group, Integer index, Function1<T, Unit> block)

        Shorthand extension function to add a View into a ViewGroup at specified index, and then run a scoped function

        Parameters:
        group - ViewGroup to add this View into
        index - Index to insert this View at
        block - A scoped function, with the View as its receiver
        Returns:

        The View

      • findViewById

         final <T extends View> T findViewById(View $self, String idName)

        The same as View.findViewById, but takes the name of the id instead.

        Parameters:
        idName - the name of the id resource
        Returns:

        a view with the given id in the layout, or null if it is not found

      • setDefaultMargins

         final <T extends View> T setDefaultMargins(T $self, Boolean bottom, Boolean top, Boolean left, Boolean right)

        Adds default discord paddings as margins to a View. By default, margins are set for the bottom, left, and right of the View, but not the top.

        Parameters:
        bottom - Whether to set topMargin.
        top - Whether to set bottomMargin.
        left - Whether to set leftMargin.
        right - Whether to set rightMargin.
        Returns:

        The View