public class

WearCurvedSpacer

extends View

implements WearArcLayout.ArcLayoutWidget

 java.lang.Object

↳View

↳androidx.wear.tiles.renderer.WearCurvedSpacer

Gradle dependencies

compile group: 'androidx.wear', name: 'wear-tiles-renderer', version: '1.0.0-alpha01'

  • groupId: androidx.wear
  • artifactId: wear-tiles-renderer
  • version: 1.0.0-alpha01

Artifact androidx.wear:wear-tiles-renderer:1.0.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

A lightweight curved widget that represents space between elements inside an Arc. This does no rendering; it simply causes the parent WearArcLayout to advance by sweepAngleDegrees.

Summary

Constructors
publicWearCurvedSpacer(Context context)

publicWearCurvedSpacer(Context context, AttributeSet attrs)

publicWearCurvedSpacer(Context context, AttributeSet attrs, int defStyleAttr)

publicWearCurvedSpacer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Methods
public voidcheckInvalidAttributeAsChild()

public floatgetSweepAngleDegrees()

public intgetThicknessPx()

public booleaninsideClickArea(float x, float y)

public voidsetSweepAngleDegrees(float sweepAngleDegrees)

Sets the sweep angle of this spacer, in degrees.

public voidsetThicknessPx(int thicknessPx)

Sets the thickness of this spacer, in DP.

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

Constructors

public WearCurvedSpacer(Context context)

public WearCurvedSpacer(Context context, AttributeSet attrs)

public WearCurvedSpacer(Context context, AttributeSet attrs, int defStyleAttr)

public WearCurvedSpacer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Methods

public float getSweepAngleDegrees()

public void setSweepAngleDegrees(float sweepAngleDegrees)

Sets the sweep angle of this spacer, in degrees.

public int getThicknessPx()

public void setThicknessPx(int thicknessPx)

Sets the thickness of this spacer, in DP.

public void checkInvalidAttributeAsChild()

public boolean insideClickArea(float x, float y)

Source

/*
 * Copyright 2021 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.wear.tiles.renderer;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;

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

/**
 * A lightweight curved widget that represents space between elements inside an Arc. This does no
 * rendering; it simply causes the parent {@link WearArcLayout} to advance by {@code
 * sweepAngleDegrees}.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class WearCurvedSpacer extends View implements WearArcLayout.ArcLayoutWidget {

    private static final float DEFAULT_SWEEP_ANGLE_DEGREES = 0f;
    private static final int DEFAULT_THICKNESS_PX = 0;

    private float mSweepAngleDegrees;
    private int mThicknessPx;

    public WearCurvedSpacer(@NonNull Context context) {
        this(context, null);
    }

    public WearCurvedSpacer(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public WearCurvedSpacer(
            @NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public WearCurvedSpacer(
            @NonNull Context context,
            @Nullable AttributeSet attrs,
            int defStyleAttr,
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WearCurvedSpacer);

        mSweepAngleDegrees =
                a.getFloat(
                        R.styleable.WearCurvedSpacer_sweepAngleDegrees,
                        DEFAULT_SWEEP_ANGLE_DEGREES);
        mThicknessPx =
                (int) a.getDimension(R.styleable.WearCurvedSpacer_thickness, DEFAULT_THICKNESS_PX);

        a.recycle();
    }

    @Override
    public float getSweepAngleDegrees() {
        return mSweepAngleDegrees;
    }

    /** Sets the sweep angle of this spacer, in degrees. */
    public void setSweepAngleDegrees(float sweepAngleDegrees) {
        this.mSweepAngleDegrees = sweepAngleDegrees;
    }

    @Override
    public int getThicknessPx() {
        return mThicknessPx;
    }

    /** Sets the thickness of this spacer, in DP. */
    public void setThicknessPx(int thicknessPx) {
        this.mThicknessPx = thicknessPx;
    }

    @Override
    public void checkInvalidAttributeAsChild() {}

    @Override
    public boolean insideClickArea(float x, float y) {
        return false;
    }
}