public class

Space

extends View

 java.lang.Object

↳View

↳androidx.legacy.widget.Space

Gradle dependencies

compile group: 'androidx.legacy', name: 'legacy-support-core-ui', version: '1.0.0'

  • groupId: androidx.legacy
  • artifactId: legacy-support-core-ui
  • version: 1.0.0

Artifact androidx.legacy:legacy-support-core-ui:1.0.0 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.legacy:legacy-support-core-ui com.android.support:support-core-ui

Androidx class mapping:

androidx.legacy.widget.Space android.support.v4.widget.Space

Overview

Space is a lightweight View subclass that may be used to create gaps between components in general purpose layouts.

Summary

Constructors
publicSpace(Context context)

publicSpace(Context context, AttributeSet attrs)

publicSpace(Context context, AttributeSet attrs, int defStyle)

Methods
public voiddraw(Canvas canvas)

Draw nothing.

protected voidonMeasure(int widthMeasureSpec, int heightMeasureSpec)

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Space(Context context, AttributeSet attrs, int defStyle)

Deprecated: Use framework class instead.

public Space(Context context, AttributeSet attrs)

Deprecated: Use framework class instead.

public Space(Context context)

Deprecated: Use framework class instead.

Methods

public void draw(Canvas canvas)

Deprecated: Use framework class instead.

Draw nothing.

Parameters:

canvas: an unused parameter.

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Deprecated: Use framework class instead.

Source

/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.legacy.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * Space is a lightweight {@link View} subclass that may be used to create gaps between components
 * in general purpose layouts.
 *
 * @deprecated Use framework {@link android.widget.Space} class instead.
 */
@Deprecated
public class Space extends View {

    /**
     * @deprecated Use framework {@link android.widget.Space} class instead.
     */
    @Deprecated
    public Space(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        if (getVisibility() == VISIBLE) {
            setVisibility(INVISIBLE);
        }
    }

    /**
     * @deprecated Use framework {@link android.widget.Space} class instead.
     */
    @Deprecated
    public Space(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    /**
     * @deprecated Use framework {@link android.widget.Space} class instead.
     */
    @Deprecated
    public Space(@NonNull Context context) {
        this(context, null);
    }

    /**
     * Draw nothing.
     *
     * @param canvas an unused parameter.
     *
     * @deprecated Use framework {@link android.widget.Space} class instead.
     */
    @Deprecated
    @Override
    @SuppressLint("MissingSuperCall")
    public void draw(Canvas canvas) {
    }

    /**
     * Compare to: {@link View#getDefaultSize(int, int)}
     * If mode is AT_MOST, return the child size instead of the parent size
     * (unless it is too big).
     */
    private static int getDefaultSize2(int size, int measureSpec) {
        int result = size;
        int specMode = MeasureSpec.getMode(measureSpec);
        int specSize = MeasureSpec.getSize(measureSpec);

        switch (specMode) {
            case MeasureSpec.UNSPECIFIED:
                result = size;
                break;
            case MeasureSpec.AT_MOST:
                result = Math.min(size, specSize);
                break;
            case MeasureSpec.EXACTLY:
                result = specSize;
                break;
        }
        return result;
    }

    /**
     * @deprecated Use framework {@link android.widget.Space} class instead.
     */
    @Deprecated
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        setMeasuredDimension(
                getDefaultSize2(getSuggestedMinimumWidth(), widthMeasureSpec),
                getDefaultSize2(getSuggestedMinimumHeight(), heightMeasureSpec));
    }
}