Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Size

@Target([AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FIELD, AnnotationTarget.ANNOTATION_CLASS]) class Size
androidx.annotation.Size

Denotes that the annotated element should have a given size or length. Note that "-1" means "unset". Typically used with a parameter or return value of type array or collection.

Example:

<code>public void getLocationInWindow(@Size(2) int[] location) {
       ...
   }
  </code>

Summary

Public constructors

<init>(value: Long, min: Long, max: Long, multiple: Long)

Denotes that the annotated element should have a given size or length.

Properties

Long

A maximum size, inclusive

Long

A minimum size, inclusive

Long

The size must be a multiple of this factor

Long

An exact size (or -1 if not specified)

Public constructors

<init>

Size(value: Long, min: Long, max: Long, multiple: Long)

Denotes that the annotated element should have a given size or length. Note that "-1" means "unset". Typically used with a parameter or return value of type array or collection.

Example:

<code>public void getLocationInWindow(@Size(2) int[] location) {
       ...
   }
  </code>

Properties

max

val max: Long

A maximum size, inclusive

min

val min: Long

A minimum size, inclusive

multiple

val multiple: Long

The size must be a multiple of this factor

value

val value: Long

An exact size (or -1 if not specified)