Java Code Examples for android.support.annotation.Px

The following are top voted examples for showing how to use android.support.annotation.Px. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Quran   File: QuranPageLayout.java   View source code 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
  View view = resolveView();
  if (view != null) {
    int width = getMeasuredWidth();
    int height = getMeasuredHeight();
    @Px int leftLineWidth = leftBorder == BorderMode.LINE ?
        1 : leftPageBorder.getIntrinsicWidth();
    @Px int rightLineWidth = rightBorder == BorderMode.HIDDEN ?
        0 : rightPageBorder.getIntrinsicWidth();
    int headerFooterHeight = 0;
    view.layout(leftLineWidth, headerFooterHeight,
        width - rightLineWidth, height - headerFooterHeight);
    super.onLayout(changed, l, t, r, b);
  }
}
 
Example 2
Project: BooheeRuler   File: VerticalRuler.java   View source code 6 votes vote down vote up
@Override
public void scrollTo(@Px int x, @Px int y) {
    if (y < mMinPosition) {
        goStartEdgeEffect(y);
        y = mMinPosition;
    }
    if (y > mMaxPosition) {
        goEndEdgeEffect(y);
        y = mMaxPosition;
    }
    if (y != getScrollY()) {
        super.scrollTo(x, y);
    }

    mCurrentScale = scrollYtoScale(y);
    if (mRulerCallback != null) {
        mRulerCallback.onScaleChanging(Math.round(mCurrentScale));
    }

}
 
Example 3
Project: BooheeRuler   File: HorizontalRuler.java   View source code 6 votes vote down vote up
@Override
public void scrollTo(@Px int x, @Px int y) {
    if (x < mMinPosition) {
        goStartEdgeEffect(x);
        x = mMinPosition;
    }
    if (x > mMaxPosition) {
        goEndEdgeEffect(x);
        x = mMaxPosition;
    }
    if (x != getScrollX()) {
        super.scrollTo(x, y);
    }

    mCurrentScale = scrollXtoScale(x);
    if (mRulerCallback != null) {
        mRulerCallback.onScaleChanging(Math.round(mCurrentScale));
    }

}
 
Example 4
Project: GitHub   File: Request.java   View source code 5 votes vote down vote up
/**
 * Resize the image to the specified size in pixels.
 * Use 0 as desired dimension to resize keeping aspect ratio.
 */
public Builder resize(@Px int targetWidth, @Px int targetHeight) {
  if (targetWidth < 0) {
    throw new IllegalArgumentException("Width must be positive number or 0.");
  }
  if (targetHeight < 0) {
    throw new IllegalArgumentException("Height must be positive number or 0.");
  }
  if (targetHeight == 0 && targetWidth == 0) {
    throw new IllegalArgumentException("At least one dimension has to be positive number.");
  }
  this.targetWidth = targetWidth;
  this.targetHeight = targetHeight;
  return this;
}
 
Example 5
Project: android_ui   File: RefreshDrawable.java   View source code 5 votes vote down vote up
/**
 * Sets the radius of the progress arc.
 *
 * @param radius The desired radius.
 * @see #getProgressRadius()
 */
public void setProgressRadius(@Px int radius) {
	if (mProgressRadius != radius) {
		this.mProgressRadius = radius;
		this.handleDrawablesSizeChange();
	}
}
 
Example 6
Project: waterfall-toolbar   File: WaterfallToolbar.java   View source code 5 votes vote down vote up
/**
 * @param value The elevation (in px) with which the toolbar starts
 * @return Own object
 */
public WaterfallToolbar setInitialElevationPx(@Px @NonNull final Integer value) {
    mInitialElevation = value;

    // gotta update elevation in case this value have
    // been set in a running and visible activity
    if (mIsSetup) adjustCardElevation();

    return this;
}
 
Example 7
Project: waterfall-toolbar   File: WaterfallToolbar.java   View source code 5 votes vote down vote up
/**
 * @param value The elevation (in px) the toolbar gets when it reaches final scroll elevation
 * @return Own object
 */
public WaterfallToolbar setFinalElevationPx(@Px @NonNull final Integer value) {
    mFinalElevation = value;

    // gotta update elevation in case this value have
    // been set in a running and visible activity
    if (mIsSetup) adjustCardElevation();

    return this;
}
 
Example 8
Project: silly-android   File: SillyAndroid.java   View source code 5 votes vote down vote up
/**
 * Sets the top and bottom padding to the given View, keeping the horizontal padding values as the were.
 *
 * @param view    Which view to set the padding to, must not be {@code null}
 * @param padding The vertical padding value
 */
public static void setPaddingVertical(@NonNull final View view, @Px final int padding) {
    final int paddingStart = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? view.getPaddingStart() : view.getPaddingLeft();
    final int paddingEnd = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ? view.getPaddingEnd() : view.getPaddingRight();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        view.setPaddingRelative(paddingStart, padding, paddingEnd, padding);
    } else {
        view.setPadding(paddingStart, padding, paddingEnd, padding);
    }
}
 
Example 9
Project: silly-android   File: SillyAndroid.java   View source code 5 votes vote down vote up
/**
 * Sets the left/start and right/end padding to the given View, keeping the vertical padding values as the were.
 *
 * @param view    Which view to set the padding to, must not be {@code null}
 * @param padding The horizontal padding value
 */
public static void setPaddingHorizontal(@NonNull final View view, @Px final int padding) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        view.setPaddingRelative(padding, view.getPaddingTop(), padding, view.getPaddingBottom());
    } else {
        view.setPadding(padding, view.getPaddingTop(), padding, view.getPaddingBottom());
    }
}
 
Example 10
Project: silly-android   File: SillyAndroid.java   View source code 5 votes vote down vote up
/**
 * Converts a {@link Drawable} into a {@link Bitmap}. Includes an optimization in case the {@link Drawable} in question is already a
 * {@link BitmapDrawable}.
 *
 * @param drawable A Drawable instance to convert
 * @param width    The width of the new Bitmap
 * @param height   The height of the new Bitmap
 * @return A new {@link Bitmap} instance constraint to width and height dimensions supplied, never {@code null}
 */
@NonNull
@SuppressWarnings("unused")
public static Bitmap drawableToBitmap(@NonNull final Drawable drawable, @Px final int width, @Px final int height) {
    final Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(result);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return result;
}
 
Example 11
Project: ViewPrinter   File: DocumentView.java   View source code 5 votes vote down vote up
@Override
public void setPadding(@Px int left, @Px int top, @Px int right, @Px int bottom) {
    if (mPager != null) {
        mPager.setPadding(left, top, right, bottom);
    } else {
        // Pass to ourselves. We will remove it in the constructor.
        super.setPadding(left, top, right, bottom);
    }
}
 
Example 12
Project: BlurPopupWindow   File: ShadowContainer.java   View source code 5 votes vote down vote up
@Override
public void setPadding(@Px int left, @Px int top, @Px int right, @Px int bottom) {
	left += mShadowRadius;
	top += mShadowRadius;
	right += mShadowRadius;
	bottom += mShadowRadius;
	super.setPadding(left, top, right, bottom);
}
 
Example 13
Project: RLibrary   File: StickLayout2.java   View source code 5 votes vote down vote up
@Override
public void scrollTo(@Px int x, @Px int y) {
    int offset = Math.min(maxScrollY, edgeScroll ? y : Math.max(0, y));
    boolean layout = false;
    if (getScrollY() != offset) {
        layout = true;
    }
    super.scrollTo(0, offset);
    if (layout) {
        requestLayout();
    }
    if (mOnScrollListener != null) {
        mOnScrollListener.onScrollTo(offset);
    }
}
 
Example 14
Project: RLibrary   File: StickLayout.java   View source code 5 votes vote down vote up
@Override
public void scrollTo(@Px int x, @Px int y) {
    int offset = Math.min(maxScrollY, Math.max(0, y));
    boolean layout = false;
    if (getScrollY() != offset) {
        layout = true;
    }
    super.scrollTo(0, offset);
    if (layout) {
        requestLayout();
    }
    if (mOnScrollListener != null) {
        mOnScrollListener.onScrollTo(offset);
    }
}
 
Example 15
Project: CameraButton   File: TypedArrayHelper.java   View source code 5 votes vote down vote up
@Px
static int getDimension(Context context,
                        TypedArray array,
                        @StyleableRes int attr,
                        @DimenRes int defaultDimenRes) {

    return array.getDimensionPixelOffset(
            attr, context.getResources().getDimensionPixelSize(defaultDimenRes));
}
 
Example 16
Project: FastTextView   File: FastTextLayoutView.java   View source code 5 votes vote down vote up
@Override
public void layout(@Px int l, @Px int t, @Px int r, @Px int b) {
  TEST_STATS.layoutStart();
  for (int i = 0; i < Const.LOOP_COUNT; i++) {
    // TODO for test
    super.layout(l, t, r, b);
  }
  TEST_STATS.layoutEnd();
}
 
Example 17
Project: FastTextView   File: FastTextView.java   View source code 5 votes vote down vote up
@Override
public void layout(@Px int l, @Px int t, @Px int r, @Px int b) {
  TEST_STATS.layoutStart();
  for (int i = 0; i < Const.LOOP_COUNT; i++) {
    // TODO for test
    super.layout(l, t, r, b);
  }
  TEST_STATS.layoutEnd();
}
 
Example 18
Project: FastTextView   File: TestTextView.java   View source code 5 votes vote down vote up
@Override
public void layout(@Px int l, @Px int t, @Px int r, @Px int b) {
  TEST_STATS.layoutStart();
  for (int i = 0; i < Const.LOOP_COUNT; i++) {
    // TODO for test
    super.layout(l, t, r, b);
  }
  TEST_STATS.layoutEnd();
}
 
Example 19
Project: ZhihuUserProfile   File: ZhihuUserProfileLayout.java   View source code 5 votes vote down vote up
@Override
public void scrollBy(@Px int x, @Px int y) {
    int targetY = getScrollY() + y;
    if (targetY >= mMaxScrollY) {
        targetY = mMaxScrollY;
    } else if (targetY <= 0) {
        targetY = 0;
    }
    super.scrollBy(x, targetY - getScrollY());
}
 
Example 20
Project: ZhihuUserProfile   File: ZhihuUserProfileLayout.java   View source code 5 votes vote down vote up
@Override
public void scrollTo(@Px int x, @Px int y) {
    if (y >= mMaxScrollY) {
        y = mMaxScrollY;
    } else if (y <= 0) {
        y = 0;
    }
    if (mOnCollapsingListener != null) {
        float progress = 1.0f - (float) y / (float) mMaxScrollY;
        if (BuildConfig.DEBUG) Log.d(TAG, "collapsing progress = " + progress);
        mOnCollapsingListener.onCollapsing(progress);
    }
    mCurrentScrollY = y;
    super.scrollTo(x, y);
}
 
Example 21
Project: EasyAndroid   File: AuthEditText.java   View source code 5 votes vote down vote up
/**
 * 设置文本大小,像素
 * @param size 文本大小
 */
public void setTextSize(@Px int size)
{
    if(size <= 0)
    {
        return;
    }

    this.textSize = size;
    for(TextView tv : list)
    {
        tv.setTextSize(textSize);
    }
}
 
Example 22
Project: RLibrary   File: RExTextView.java   View source code 5 votes vote down vote up
@Override
public void scrollTo(@Px int x, @Px int y) {
    if (maxShowLine > 0) {
        return;
    }
    super.scrollTo(x, y);
}
 
Example 23
Project: Customerly-Android-SDK   File: IU_Utils.java   View source code 5 votes vote down vote up
@Contract(pure = true)
@Px static int px(@Dimension(unit = Dimension.DP) int dp) {
    float dpi = Resources.getSystem().getDisplayMetrics().density;
    dpi = dpi > 100/*120, 160, 213, 240, 320, 480 or 640 dpi*/ ? dpi / 160f : dpi;
    dpi = dpi == 0 ? 1f : dpi;
    return (int) (dp * dpi);
}
 
Example 24
Project: GitHub   File: RefreshLayout.java   View source code 4 votes vote down vote up
@Override
public void scrollTo(@Px int x, @Px int y) {
    super.scrollTo(x, y);
}
 
Example 25
Project: BookLoadingView   File: BookLoadingView.java   View source code 4 votes vote down vote up
public void setTickStrokeWidth(@Px int strokeWidth) {
    mTickView.setStrokeWidth(strokeWidth);
}
 
Example 26
Project: code-scanner   File: ViewFinderView.java   View source code 4 votes vote down vote up
void setFrameThickness(@Px int thickness) {
    mFramePaint.setStrokeWidth(thickness);
    if (Utils.isLaidOut(this)) {
        invalidate();
    }
}
 
Example 27
Project: code-scanner   File: ViewFinderView.java   View source code 4 votes vote down vote up
void setFrameCornersSize(@Px int size) {
    mFrameCornerSize = size;
    if (Utils.isLaidOut(this)) {
        invalidate();
    }
}
 
Example 28
Project: Android-Spans   File: Span.java   View source code 4 votes vote down vote up
public static Node absoluteSize(@Px Integer size, Object... nodes) {
    return new SpanNode(new AbsoluteSizeSpan(size), nodes);
}
 
Example 29
Project: Android-Spans   File: Span.java   View source code 4 votes vote down vote up
public static Node absoluteSize(@Px Integer size, Boolean dip, Object... nodes) {
    return new SpanNode(new AbsoluteSizeSpan(size, dip), nodes);
}
 
Example 30
Project: Android-Spans   File: Span.java   View source code 4 votes vote down vote up
public static Node bullet(@Px Integer gapWidth, Object... nodes) {
    return new SpanNode(new BulletSpan(gapWidth), nodes);
}
 
Example 31
Project: Android-Spans   File: Span.java   View source code 4 votes vote down vote up
public static Node drawableMargin(Drawable drawable, @Px Integer padding, Object... nodes) {
    return new SpanNode(new DrawableMarginSpan(drawable, padding), nodes);
}
 
Example 32
Project: Android-Spans   File: Span.java   View source code 4 votes vote down vote up
public static Node iconMargin(Bitmap bitmap, @Px Integer padding, Object... nodes) {
    return new SpanNode(new IconMarginSpan(bitmap, padding), nodes);
}
 
Example 33
Project: RoundedLayout   File: RoundedLayout.java   View source code 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override public void setElevation(@Px float elevation) {
    super.setElevation(elevation);
    mRoundingElevation = elevation;
}
 
Example 34
Project: silly-android   File: EasyFragment.java   View source code 4 votes vote down vote up
/**
 * Invokes {@link SillyAndroid#setPadding(View, int, int, int, int)} with the same arguments.
 */
protected final void setPadding(@NonNull final View view, @Px final int start, @Px final int top, @Px final int end, @Px final int bottom) {
    SillyAndroid.setPadding(view, start, top, end, bottom);
}
 
Example 35
Project: silly-android   File: EasyFragment.java   View source code 4 votes vote down vote up
/**
 * Invokes the {@link SillyAndroid#setPaddingVertical(View, int)} with the same arguments.
 */
protected final void setPaddingVertical(@NonNull final View view, @Px final int padding) {
    SillyAndroid.setPaddingVertical(view, padding);
}
 
Example 36
Project: silly-android   File: EasyFragment.java   View source code 4 votes vote down vote up
/**
 * Invokes the {@link SillyAndroid#setPaddingHorizontal(View, int)} with the same arguments.
 */
protected final void setPaddingHorizontal(@NonNull final View view, @Px final int padding) {
    SillyAndroid.setPaddingHorizontal(view, padding);
}
 
Example 37
Project: silly-android   File: EasyFragment.java   View source code 4 votes vote down vote up
/**
 * Invokes {@link SillyAndroid#setPadding(View, int)} with the same arguments.
 */
protected final void setPadding(@NonNull final View view, @Px final int padding) {
    SillyAndroid.setPadding(view, padding);
}
 
Example 38
Project: silly-android   File: EasyDialog.java   View source code 4 votes vote down vote up
/**
 * Invokes {@link SillyAndroid#setPadding(View, int, int, int, int)} with the same arguments.
 */
protected final void setPadding(@NonNull final View view, @Px final int start, @Px final int top, @Px final int end, @Px final int bottom) {
    SillyAndroid.setPadding(view, start, top, end, bottom);
}
 
Example 39
Project: silly-android   File: EasyDialog.java   View source code 4 votes vote down vote up
/**
 * Invokes the {@link SillyAndroid#setPaddingVertical(View, int)} with the same arguments.
 */
protected final void setPaddingVertical(@NonNull final View view, @Px final int padding) {
    SillyAndroid.setPaddingVertical(view, padding);
}
 
Example 40
Project: silly-android   File: EasyDialog.java   View source code 4 votes vote down vote up
/**
 * Invokes the {@link SillyAndroid#setPaddingHorizontal(View, int)} with the same arguments.
 */
protected final void setPaddingHorizontal(@NonNull final View view, @Px final int padding) {
    SillyAndroid.setPaddingHorizontal(view, padding);
}