本文整理匯總了Java中android.support.annotation.Px類的典型用法代碼示例。如果您正苦於以下問題:Java Px類的具體用法?Java Px怎麽用?Java Px使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Px類屬於android.support.annotation包,在下文中一共展示了Px類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onLayout
import android.support.annotation.Px; //導入依賴的package包/類
@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);
}
}
示例2: scrollTo
import android.support.annotation.Px; //導入依賴的package包/類
@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));
}
}
示例3: scrollTo
import android.support.annotation.Px; //導入依賴的package包/類
@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));
}
}
示例4: resize
import android.support.annotation.Px; //導入依賴的package包/類
/**
* 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;
}
示例5: setProgressRadius
import android.support.annotation.Px; //導入依賴的package包/類
/**
* 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();
}
}
示例6: setInitialElevationPx
import android.support.annotation.Px; //導入依賴的package包/類
/**
* @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;
}
示例7: setFinalElevationPx
import android.support.annotation.Px; //導入依賴的package包/類
/**
* @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;
}
示例8: setPaddingVertical
import android.support.annotation.Px; //導入依賴的package包/類
/**
* 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);
}
}
示例9: setPaddingHorizontal
import android.support.annotation.Px; //導入依賴的package包/類
/**
* 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());
}
}
示例10: drawableToBitmap
import android.support.annotation.Px; //導入依賴的package包/類
/**
* 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;
}
示例11: setPadding
import android.support.annotation.Px; //導入依賴的package包/類
@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);
}
}
示例12: setPadding
import android.support.annotation.Px; //導入依賴的package包/類
@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);
}
示例13: scrollTo
import android.support.annotation.Px; //導入依賴的package包/類
@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);
}
}
示例14: scrollTo
import android.support.annotation.Px; //導入依賴的package包/類
@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);
}
}
示例15: getDimension
import android.support.annotation.Px; //導入依賴的package包/類
@Px
static int getDimension(Context context,
TypedArray array,
@StyleableRes int attr,
@DimenRes int defaultDimenRes) {
return array.getDimensionPixelOffset(
attr, context.getResources().getDimensionPixelSize(defaultDimenRes));
}