当前位置: 首页>>代码示例>>Java>>正文


Java Resources.getDimension方法代码示例

本文整理汇总了Java中android.content.res.Resources.getDimension方法的典型用法代码示例。如果您正苦于以下问题:Java Resources.getDimension方法的具体用法?Java Resources.getDimension怎么用?Java Resources.getDimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.getDimension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaultKeyboardHeight

import android.content.res.Resources; //导入方法依赖的package包/类
public static int getDefaultKeyboardHeight(final Resources res) {
    final DisplayMetrics dm = res.getDisplayMetrics();
    final String keyboardHeightInDp = getDeviceOverrideValue(
            res, R.array.keyboard_heights, null /* defaultValue */);
    final float keyboardHeight;
    if (TextUtils.isEmpty(keyboardHeightInDp)) {
        keyboardHeight = res.getDimension(R.dimen.config_default_keyboard_height);
    } else {
        keyboardHeight = Float.parseFloat(keyboardHeightInDp) * dm.density;
    }
    final float maxKeyboardHeight = res.getFraction(
            R.fraction.config_max_keyboard_height, dm.heightPixels, dm.heightPixels);
    float minKeyboardHeight = res.getFraction(
            R.fraction.config_min_keyboard_height, dm.heightPixels, dm.heightPixels);
    if (minKeyboardHeight < 0.0f) {
        // Specified fraction was negative, so it should be calculated against display
        // width.
        minKeyboardHeight = -res.getFraction(
                R.fraction.config_min_keyboard_height, dm.widthPixels, dm.widthPixels);
    }
    // Keyboard height will not exceed maxKeyboardHeight and will not be less than
    // minKeyboardHeight.
    return (int)Math.max(Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:25,代码来源:ResourceUtils.java

示例2: onApplyWindowInsets

import android.content.res.Resources; //导入方法依赖的package包/类
@Override
public void onApplyWindowInsets(WindowInsets insets) {
    super.onApplyWindowInsets(insets);

    // Load resources that have alternate values for round watches.
    Resources resources = MyWatchFace.this.getResources();
    boolean isRound = insets.isRound();
    mXOffset = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);
    float textSize = resources.getDimension(isRound
            ? R.dimen.digital_text_size_round : R.dimen.digital_text_size);


    hourPaint.setTextSize(textSize);
    minutePaint.setTextSize(textSize);
    colonPaint.setTextSize(textSize);
    highPaint.setTextSize(textSize);
    lowPaint.setTextSize(textSize);
    colonWidth = colonPaint.measureText(":");
}
 
开发者ID:changja88,项目名称:Android_Sunshine_Watch,代码行数:21,代码来源:MyWatchFace.java

示例3: getItemOffsets

import android.content.res.Resources; //导入方法依赖的package包/类
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    Resources r = context.getResources();
    int horizontalPadding = (int) r.getDimension(R.dimen.category_preview__app_list__padding__horizontal);
    int horizontalPaddingFirst = (int) r.getDimension(
            R.dimen.category_preview__app_list__padding__horizontal__first);
    boolean isLtr = ViewCompat.getLayoutDirection(parent) == ViewCompat.LAYOUT_DIRECTION_LTR;
    int itemPosition = parent.getChildLayoutPosition(view);
    boolean first = itemPosition == 0;

    // Leave this "paddingEnd" local variable here for clarity when converting from
    // left/right to start/end for RTL friendly layout.
    // noinspection UnnecessaryLocalVariable
    int paddingEnd = horizontalPadding;
    int paddingStart = first ? horizontalPaddingFirst : horizontalPadding;

    int paddingLeft = isLtr ? paddingStart : paddingEnd;
    int paddingRight = isLtr ? paddingEnd : paddingStart;
    outRect.set(paddingLeft, 0, paddingRight, 0);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:21,代码来源:CategoryController.java

示例4: measureInWindow

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Returns the coordinates of a view relative to the window (not just the RootView
 * which is what measure will return)
 *
 * @param tag - the tag for the view
 * @param outputBuffer - output buffer that contains [x,y,width,height] of the view in coordinates
 *  relative to the device window
 */
public void measureInWindow(int tag, int[] outputBuffer) {
  UiThreadUtil.assertOnUiThread();
  View v = mTagsToViews.get(tag);
  if (v == null) {
    throw new NoSuchNativeViewException("No native view for " + tag + " currently exists");
  }

  v.getLocationOnScreen(outputBuffer);

  // We need to remove the status bar from the height.  getLocationOnScreen will include the
  // status bar.
  Resources resources = v.getContext().getResources();
  int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android");
  if (statusBarId > 0) {
    int height = (int) resources.getDimension(statusBarId);
    outputBuffer[1] -= height;
  }

  // outputBuffer[0,1] already contain what we want
  outputBuffer[2] = v.getWidth();
  outputBuffer[3] = v.getHeight();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:31,代码来源:NativeViewHierarchyManager.java

示例5: ControllerV16

import android.content.res.Resources; //导入方法依赖的package包/类
public ControllerV16(View header) {
    Resources res = header.getContext().getResources();
    mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);

    mShadow = new View(header.getContext());
    mShadow.setBackground(new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM, new int[] {0x1E000000, 0x00000000}));
    mShadow.setAlpha(0);

    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            res.getDimensionPixelSize(R.dimen.all_apps_header_shadow_height));
    lp.topMargin = ((FrameLayout.LayoutParams) header.getLayoutParams()).height;

    ((ViewGroup) header.getParent()).addView(mShadow, lp);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:17,代码来源:HeaderElevationController.java

示例6: setIsUsingBigIcon

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Adjusts styling to account for the big icon layout.
 */
public void setIsUsingBigIcon() {
    LayoutParams lp = (LayoutParams) mIconView.getLayoutParams();
    lp.width = mBigIconSize;
    lp.height = mBigIconSize;
    lp.endMargin = mBigIconMargin;

    Resources res = getContext().getResources();
    String typeface = res.getString(R.string.roboto_medium_typeface);
    int textStyle = res.getInteger(R.integer.roboto_medium_textstyle);
    float textSize = res.getDimension(R.dimen.infobar_big_icon_message_size);
    mMessageTextView.setTypeface(Typeface.create(typeface, textStyle));
    mMessageTextView.setMaxLines(1);
    mMessageTextView.setEllipsize(TextUtils.TruncateAt.END);
    mMessageTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:InfoBarLayout.java

示例7: getHeaderFooterRowHeight

import android.content.res.Resources; //导入方法依赖的package包/类
public int getHeaderFooterRowHeight(int section, boolean isFooterRow) {
    Resources res = mTableView.getResources();

    // pull height, it will default on delegate to UNDEFINED if not
    // overridden.
    int rowHeight = ATableViewCell.LayoutParams.UNDEFINED;
    if (isFooterRow) {
        rowHeight = section < mFootersHeight.size() ? mFootersHeight.get(section) : 0;
    } else {
        rowHeight = section < mHeadersHeight.size() ? mHeadersHeight.get(section) : 0;
    }

    // if undefined, set a valid height depending on table style, otherwise
    // use overridden value.
    if (rowHeight == ATableViewCell.LayoutParams.UNDEFINED) {
        if (mTableView.getStyle() == ATableViewStyle.Plain) {
            rowHeight = (int) res
                    .getDimension(R.dimen.atv_plain_section_header_height);
        } else {
            rowHeight = ListView.LayoutParams.WRAP_CONTENT;
        }
    }

    // convert row height value when an scalar was used.
    if (rowHeight > -1) {
        rowHeight = (int) Math.ceil(rowHeight
                * res.getDisplayMetrics().density);
    }

    return rowHeight;
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:32,代码来源:ATableViewAdapter.java

示例8: CirclePageIndicator

import android.content.res.Resources; //导入方法依赖的package包/类
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
      setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:CirclePageIndicator.java

示例9: initializeWatchFaceElements

import android.content.res.Resources; //导入方法依赖的package包/类
private void initializeWatchFaceElements(Resources resources){

            mBackgroundPaint = new Paint();
            mBackgroundPaint.setColor(resources.getColor(R.color.background));


            mTimeTextPaint = new Paint();
            mTimeTextPaint.setColor(resources.getColor(R.color.digital_time));
            mTimeTextPaint.setTypeface(NORMAL_TYPEFACE);
            mTimeTextPaint.setAntiAlias(true);

            mDateTextPaint = new Paint();
            mDateTextPaint.setTextSize(resources.getDimension(R.dimen.digital_text_date_size));
            mDateTextPaint.setColor(resources.getColor(R.color.digital_date));
            mDateTextPaint.setTypeface(NORMAL_TYPEFACE);
            mDateTextPaint.setAntiAlias(true);

            mIconBitmappaint=new Paint();

            mMaxTempTextPaint= new Paint();
            mMaxTempTextPaint.setColor(resources.getColor(R.color.digital_maxT));
            mMaxTempTextPaint.setTextSize(resources.getDimension(R.dimen.digital_text_MaxT_size));
            mMaxTempTextPaint.setTypeface(NORMAL_TYPEFACE);
            mMaxTempTextPaint.setAntiAlias(true);

            mMinTempTextPaint= new Paint();
            mMinTempTextPaint.setColor(resources.getColor(R.color.digital_minT));
            mMinTempTextPaint.setTextSize(resources.getDimension(R.dimen.digital_text_MinT_size));
            mMinTempTextPaint.setTypeface(NORMAL_TYPEFACE);
            mMinTempTextPaint.setAntiAlias(true);

            mYOffset = resources.getDimension(R.dimen.digital_y_offset);
            mCalendar = Calendar.getInstance();
            mDate = new Date();

        }
 
开发者ID:gmontoya2483,项目名称:GoUbiquitous,代码行数:37,代码来源:DigitalWatchFaceService.java

示例10: CirclePageIndicator

import android.content.res.Resources; //导入方法依赖的package包/类
public CirclePageIndicator(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:41,代码来源:CirclePageIndicator.java

示例11: loadDimens

import android.content.res.Resources; //导入方法依赖的package包/类
private void loadDimens() {
    Resources res = getContext().getResources();
    this.mSelfExpandVelocityPx = res.getDimension(R.dimen.self_expand_velocity);
    this.mSelfCollapseVelocityPx = res.getDimension(R.dimen.self_collapse_velocity);
    this.mFlingExpandMinVelocityPx = res.getDimension(R.dimen.fling_expand_min_velocity);
    this.mFlingCollapseMinVelocityPx = res.getDimension(R.dimen.fling_collapse_min_velocity);
    this.mFlingGestureMinDistPx = res.getDimension(R.dimen.fling_gesture_min_dist);
    this.mCollapseMinDisplayFraction = res.getFraction(R.fraction.collapse_min_display_fraction, 1, 1);
    this.mExpandMinDisplayFraction = res.getFraction(R.fraction.expand_min_display_fraction, 1, 1);
    this.mExpandAccelPx = res.getDimension(R.dimen.expand_accel);
    this.mCollapseAccelPx = res.getDimension(R.dimen.collapse_accel);
    this.mFlingGestureMaxXVelocityPx = res.getDimension(R.dimen.fling_gesture_max_x_velocity);
    this.mFlingGestureMaxOutputVelocityPx = res.getDimension(R.dimen.fling_gesture_max_output_velocity);
    this.mPeekHeight = (((float) getPaddingBottom()) + res.getDimension(R.dimen.peek_height)) - ((float) (this.mHandleView == null ? 0 : this.mHandleView.getPaddingTop()));
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:16,代码来源:PanelView.java

示例12: attachToRecyclerView

import android.content.res.Resources; //导入方法依赖的package包/类
public void attachToRecyclerView(@Nullable RecyclerView recyclerView) {
    if (this.mRecyclerView != recyclerView) {
        if (this.mRecyclerView != null) {
            destroyCallbacks();
        }
        this.mRecyclerView = recyclerView;
        if (this.mRecyclerView != null) {
            Resources resources = recyclerView.getResources();
            this.mSwipeEscapeVelocity = resources.getDimension(R.dimen.item_touch_helper_swipe_escape_velocity);
            this.mMaxSwipeVelocity = resources.getDimension(R.dimen.item_touch_helper_swipe_escape_max_velocity);
            setupCallbacks();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:15,代码来源:ItemTouchHelper.java

示例13: CirclePageIndicator

import android.content.res.Resources; //导入方法依赖的package包/类
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mPaintPageFill = new Paint(1);
    this.mPaintStroke = new Paint(1);
    this.mPaintFill = new Paint(1);
    this.mLastMotionX = -1.0f;
    this.mActivePointerId = -1;
    if (!isInEditMode()) {
        Resources res = getResources();
        int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
        int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
        int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
        int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
        float defaultStrokeWidth = res.getDimension(R.dimen
                .default_circle_indicator_stroke_width);
        float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
        boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
        boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator,
                defStyle, 0);
        this.mCentered = a.getBoolean(2, defaultCentered);
        this.mOrientation = a.getInt(0, defaultOrientation);
        this.mPaintPageFill.setStyle(Style.FILL);
        this.mPaintPageFill.setColor(a.getColor(5, defaultPageColor));
        this.mPaintStroke.setStyle(Style.STROKE);
        this.mPaintStroke.setColor(a.getColor(8, defaultStrokeColor));
        this.mPaintStroke.setStrokeWidth(a.getDimension(3, defaultStrokeWidth));
        this.mPaintFill.setStyle(Style.FILL);
        this.mPaintFill.setColor(a.getColor(4, defaultFillColor));
        this.mRadius = a.getDimension(6, defaultRadius);
        this.mSnap = a.getBoolean(7, defaultSnap);
        Drawable background = a.getDrawable(1);
        if (background != null) {
            setBackgroundDrawable(background);
        }
        a.recycle();
        this.mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfiguration
                .get(context));
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:41,代码来源:CirclePageIndicator.java

示例14: HolographicOutlineHelper

import android.content.res.Resources; //导入方法依赖的package包/类
private HolographicOutlineHelper(Context context) {
    Resources res = context.getResources();

    float mediumBlur = res.getDimension(R.dimen.blur_size_medium_outline);
    mMediumOuterBlurMaskFilter = new BlurMaskFilter(mediumBlur, BlurMaskFilter.Blur.OUTER);
    mMediumInnerBlurMaskFilter = new BlurMaskFilter(mediumBlur, BlurMaskFilter.Blur.NORMAL);

    mThinOuterBlurMaskFilter = new BlurMaskFilter(
            res.getDimension(R.dimen.blur_size_thin_outline), BlurMaskFilter.Blur.OUTER);

    mShadowBitmapShift = res.getDimension(R.dimen.blur_size_click_shadow);
    mShadowBlurMaskFilter = new BlurMaskFilter(mShadowBitmapShift, BlurMaskFilter.Blur.NORMAL);

    mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:16,代码来源:HolographicOutlineHelper.java

示例15: initDefaultAttrs

import android.content.res.Resources; //导入方法依赖的package包/类
private void initDefaultAttrs(Context context) {
    Resources resources = context.getResources();

    underlineReductionScale = DEFAULT_REDUCTION_SCALE;
    underlineStrokeWidth = resources.getDimension(R.dimen.underline_stroke_width);
    underlineBaseColor = ContextCompat.getColor(context, R.color.underline_base_color);
    underlineFilledColor = ContextCompat.getColor(context, R.color.underline_filled_color);
    underlineCursorColor = ContextCompat.getColor(context, R.color.underline_cursor_color);
    underlineSelectedColor = ContextCompat.getColor(context, R.color.underline_selected_color);
    textSize = resources.getDimension(R.dimen.code_text_size);
    textColor = ContextCompat.getColor(context, R.color.text_main_color);
    codeLength = DEFAULT_CODE_LENGTH;
    codeHiddenMask = DEFAULT_CODE_MASK;
}
 
开发者ID:Onum,项目名称:EditCodeView,代码行数:15,代码来源:EditCodeView.java


注:本文中的android.content.res.Resources.getDimension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。