Codota Logo
AppCompatImageView.onMeasure
Code IndexAdd Codota to your IDE (free)

How to use
onMeasure
method
in
androidx.appcompat.widget.AppCompatImageView

Best Java code snippets using androidx.appcompat.widget.AppCompatImageView.onMeasure (Showing top 6 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: alexvasilkov/GestureViews

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  int width = MeasureSpec.getSize(widthMeasureSpec);
  int widthMode = MeasureSpec.getMode(widthMeasureSpec);
  int height = MeasureSpec.getSize(heightMeasureSpec);
  int heightMode = MeasureSpec.getMode(heightMeasureSpec);
  if (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST) {
    height = calculate(width, aspect, VERTICAL);
  } else if (heightMode == MeasureSpec.EXACTLY || heightMode == MeasureSpec.AT_MOST) {
    width = calculate(height, aspect, HORIZONTAL);
  } else if (width != 0) {
    height = calculate(width, aspect, VERTICAL);
  } else if (height != 0) {
    width = calculate(height, aspect, HORIZONTAL);
  } else {
    Log.e(AspectImageView.class.getSimpleName(),
        "Either width or height should have exact value");
  }
  int specWidth = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
  int specHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
  super.onMeasure(specWidth, specHeight);
}
origin: google/santa-tracker-android

  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    Drawable drawable = getDrawable();

    if (drawable != null) {
      int width = MeasureSpec.getSize(widthMeasureSpec);
      int diw = drawable.getIntrinsicWidth();
      if (diw > 0) {
        int height = width * drawable.getIntrinsicHeight() / diw;
        setMeasuredDimension(width, height);
        return;
      }
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}
origin: darkskygit/VirtualApp

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  if (mIsSquare) {
    int measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
    int size = measuredWidth == 0 ? MeasureSpec.getSize(heightMeasureSpec) : measuredWidth;
    setMeasuredDimension(size, size);
  }
}
origin: AndroidDeveloperLB/MaterialPreferenceLibrary

  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    if (widthMode == MeasureSpec.AT_MOST || widthMode == MeasureSpec.UNSPECIFIED) {
      final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
      final int maxWidth = getMaxWidth();
      if (maxWidth != Integer.MAX_VALUE
          && (maxWidth < widthSize || widthMode == MeasureSpec.UNSPECIFIED)) {
        widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST);
      }
    }

    final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    if (heightMode == MeasureSpec.AT_MOST || heightMode == MeasureSpec.UNSPECIFIED) {
      final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
      final int maxHeight = getMaxHeight();
      if (maxHeight != Integer.MAX_VALUE
          && (maxHeight < heightSize || heightMode == MeasureSpec.UNSPECIFIED)) {
        heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
      }
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}
origin: gateship-one/odyssey

  /**
   * Adjust Dimensions to create a square image view that matches the parents width.
   */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    int width = getMeasuredWidth();
    setMeasuredDimension(width, width);
  }
}
origin: AlexMofer/ProjectX

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  int size;
  if (mSize <= 0)
    size = (int) Math.ceil(
        (mProgress.getCenterRadius() + mProgress.getStrokeWidth() + mPaddingEdge) * 2);
  else
    size = (int) Math.ceil(mSize);
  if (mShowShadowsCircle && !elevationSupported()) {
    size += Math.round(mElevation * 2);
  }
  setMeasuredDimension(resolveSize(size, widthMeasureSpec),
      resolveSize(size, heightMeasureSpec));
}
androidx.appcompat.widgetAppCompatImageViewonMeasure

Popular methods of AppCompatImageView

  • setImageDrawable
  • setImageResource
  • onDraw
  • onSizeChanged
  • setImageURI
  • setImageBitmap
  • setScaleType
  • setVisibility
  • drawableStateChanged
  • getDrawable
  • onRestoreInstanceState
  • onSaveInstanceState
  • onRestoreInstanceState,
  • onSaveInstanceState,
  • setFrame,
  • verifyDrawable,
  • draw,
  • drawableHotspotChanged,
  • invalidateDrawable,
  • jumpDrawablesToCurrentState,
  • onAttachedToWindow

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • orElseThrow (Optional)
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Hashtable (java.util)
    Hashtable is a synchronized implementation of Map. All optional operations are supported.Neither key
  • JComboBox (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now