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


Java TypedArray.getInt方法代码示例

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


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

示例1: initAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initAttributes(Context context, AttributeSet attributeSet) {
    TypedArray attr = getTypedArray(context, attributeSet, R.styleable.FloatingActionButton);
    if (attr != null) {
        try {
            mColorNormal = attr.getColor(R.styleable.FloatingActionButton_fab_colorNormal,
                    getColor(R.color.material_blue_500));
            mColorPressed = attr.getColor(R.styleable.FloatingActionButton_fab_colorPressed,
                    darkenColor(mColorNormal));
            mColorRipple = attr.getColor(R.styleable.FloatingActionButton_fab_colorRipple,
                    lightenColor(mColorNormal));
            mColorDisabled = attr.getColor(R.styleable.FloatingActionButton_fab_colorDisabled,
                    mColorDisabled);
            mShadow = attr.getBoolean(R.styleable.FloatingActionButton_fab_shadow, true);
            mType = attr.getInt(R.styleable.FloatingActionButton_fab_type, TYPE_NORMAL);
        } finally {
            attr.recycle();
        }
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:20,代码来源:FloatingActionButton.java

示例2: CameraBridgeViewBase

import android.content.res.TypedArray; //导入方法依赖的package包/类
public CameraBridgeViewBase(Context context, AttributeSet attrs) {
    super(context, attrs);

    int count = attrs.getAttributeCount();
    Log.d(TAG, "Attr count: " + Integer.valueOf(count));

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
        enableFpsMeter();

    mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);

    getHolder().addCallback(this);
    mMaxWidth = MAX_UNSPECIFIED;
    mMaxHeight = MAX_UNSPECIFIED;
    styledAttrs.recycle();
}
 
开发者ID:TheBigBombman,项目名称:RobotIGS,代码行数:18,代码来源:CameraBridgeViewBase.java

示例3: CameraGLSurfaceView

import android.content.res.TypedArray; //导入方法依赖的package包/类
public CameraGLSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
    int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
    styledAttrs.recycle();

    if(android.os.Build.VERSION.SDK_INT >= 21)
        mRenderer = new Camera2Renderer(this);
    else
        mRenderer = new CameraRenderer(this);

    setCameraIndex(cameraIndex);

    setEGLContextClientVersion(2);
    setRenderer(mRenderer);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
开发者ID:johnhany,项目名称:MOAAP,代码行数:19,代码来源:CameraGLSurfaceView.java

示例4: resolveGravityEnum

import android.content.res.TypedArray; //导入方法依赖的package包/类
public static GravityEnum resolveGravityEnum(Context context,
                                             @AttrRes int attr,
                                             GravityEnum defaultGravity) {
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
    try {
        switch (a.getInt(0, gravityEnumToAttrInt(defaultGravity))) {
            case 1:
                return GravityEnum.CENTER;
            case 2:
                return GravityEnum.END;
            default:
                return GravityEnum.START;
        }
    } finally {
        a.recycle();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:DialogUtils.java

示例5: ForegroundLinearLayout

import android.content.res.TypedArray; //导入方法依赖的package包/类
public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mSelfBounds = new Rect();
    this.mOverlayBounds = new Rect();
    this.mForegroundGravity = Opcodes.INVOKE_STATIC_RANGE;
    this.mForegroundInPadding = true;
    this.mForegroundBoundsChanged = false;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLinearLayout, defStyle, 0);
    this.mForegroundGravity = a.getInt(R.styleable.ForegroundLinearLayout_android_foregroundGravity, this.mForegroundGravity);
    Drawable d = a.getDrawable(R.styleable.ForegroundLinearLayout_android_foreground);
    if (d != null) {
        setForeground(d);
    }
    this.mForegroundInPadding = a.getBoolean(R.styleable.ForegroundLinearLayout_foregroundInsidePadding, true);
    a.recycle();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:ForegroundLinearLayout.java

示例6: init

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
    // Load attributes
    try {
        final TypedArray a = getContext().obtainStyledAttributes(
                attrs, R.styleable.SimpleViewPager, defStyle, 0);

        mDotColor = a.getColor(R.styleable.SimpleViewPager_dotColor, Color.BLACK);
        mDotColorActive = a.getColor(R.styleable.SimpleViewPager_dotColorActive, Color.WHITE);
        mSwipeAnimationDuration = a.getInt(R.styleable.SimpleViewPager_swipeAnimationDuration, 300);
        mSwipeSensitivity = a.getInt(R.styleable.SimpleViewPager_swipeSensitivity, 300);
        mPageDotsAlignment = PageDotsAlignment.values()[(a.getInt(R.styleable.SimpleViewPager_pageDotsAlignment, 1))];
        mPageDotsMargin = (int) a.getDimension(R.styleable.SimpleViewPager_pageDotsMargin, 100);
        mDotRadius = (int) a.getDimension(R.styleable.SimpleViewPager_pageDotsRadius, 20);
        mActivePageDotsRadius = (int) a.getDimension(R.styleable.SimpleViewPager_activePageDotsRadius, mDotRadius);
        mDotsSeparate = (int) a.getDimension(R.styleable.SimpleViewPager_dotsSeperate, 10);
        mShowPageDots = a.getBoolean(R.styleable.SimpleViewPager_showPageDots, true);
        a.recycle();

    } catch (Exception ex) {
        ex.printStackTrace();
    }

    setOnTouchListener(_OnTouchListener);
    mPagerView = new View(getContext());
    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(ALIGN_PARENT_BOTTOM);
    mPagerView.setLayoutParams(layoutParams);
    addView(mPagerView);
    mPagerView.bringToFront();

}
 
开发者ID:savmm,项目名称:AndroidSimpleViews,代码行数:32,代码来源:SimpleViewPager.java

示例7: initViews

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initViews(Context context, AttributeSet attrs) {
    tipCornerPosition = TIP_POSITION_TOP_LEFT;//默认左上角
    startDisH = dp2px(context, 20);//20dp
    textVPadding = dp2px(context, 2);//3dp
    tipTextSize = sp2px(context, 11);//11sp
    tipTextColor = Color.WHITE;//默认字体白色
    tipBackgroundColor = Color.TRANSPARENT;//默认透明背景

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CornerTipView);
    tipCornerPosition = typedArray.getInt(R.styleable.CornerTipView_tip_corner_position, tipCornerPosition);
    realStartDisH = typedArray.getDimensionPixelSize(R.styleable.CornerTipView_tip_start_dis_x, (int) startDisH);
    textVPadding = typedArray.getDimensionPixelSize(R.styleable.CornerTipView_tip_text_v_padding, textVPadding);
    tipTextSize = typedArray.getDimensionPixelSize(R.styleable.CornerTipView_tip_text_size, tipTextSize);//默认12sp
    tipTextColor = typedArray.getColor(R.styleable.CornerTipView_tip_text_color, tipTextColor);
    tipBackgroundColor = typedArray.getColor(R.styleable.CornerTipView_tip_background, tipBackgroundColor);
    tipContent = typedArray.getString(R.styleable.CornerTipView_tip_text);
    typedArray.recycle();

    path = new Path();
    backPaint = new Paint();
    backPaint.setAntiAlias(true);
    backPaint.setColor(tipBackgroundColor);

    textPaint = new TextPaint();
    textPaint.setColor(tipTextColor);
    textPaint.setTextSize(tipTextSize);
    textPaint.setTextAlign(Paint.Align.CENTER);
}
 
开发者ID:zhqchen,项目名称:CornerTipView,代码行数:29,代码来源:CornerTipView.java

示例8: ShapedViewSettings

import android.content.res.TypedArray; //导入方法依赖的package包/类
public ShapedViewSettings(Context context, AttributeSet attrs) {
    TypedArray styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.ShapedDrawer, 0, 0);
    final int shape = styledAttributes.getInt(R.styleable.ShapedDrawer_drawerShape, NORMAL);
    switch (shape) {
        case 0:
            shapeType = ARC_CONCAVE;
            break;
        case 1:
            shapeType = ARC_CONVEX;
            break;
        case 2:
            shapeType = ROUNDED_RECT;
            break;
        case 3:
            shapeType = WAVES;
            break;
        case 4:
            shapeType = BOTTOM_ROUND;
            break;
        case 5:
            shapeType = FULL_ROUND;
            break;
        case 6:
            shapeType = WAVES_INDEFINITE;
            break;
        default:
            shapeType = NORMAL;
    }

    int[] attrsArray = new int[]{
            android.R.attr.background,
            android.R.attr.layout_gravity,
    };

    TypedArray androidAttrs = context.obtainStyledAttributes(attrs, attrsArray);
    backgroundDrawable = androidAttrs.getDrawable(0);

    androidAttrs.recycle();
    styledAttributes.recycle();
}
 
开发者ID:naseemali925,项目名称:ShapedNavigationView,代码行数:41,代码来源:ShapedViewSettings.java

示例9: initAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
protected void initAttributes(Context context, AttributeSet attributeSet) {
    TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.FloatActionButton, 0, 0);
    if (attr != null) {
        try {
            mColorNormal = attr.getColor(R.styleable.FloatActionButton_urv_fab_colorNormal, getColor(android.R.color.holo_blue_dark));
            mColorPressed = attr.getColor(R.styleable.FloatActionButton_urv_fab_colorPressed, getColor(android.R.color.holo_blue_light));
            mSize = attr.getInt(R.styleable.FloatActionButton_urv_fab_size, SIZE_NORMAL);
            mIcon = attr.getResourceId(R.styleable.FloatActionButton_icon, 0);
            load_extended_attributes(attr);
        } finally {
            attr.recycle();
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:FloatingActionButton.java

示例10: obtainAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void obtainAttributes(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout);

    mIndicatorStyle = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_style, STYLE_NORMAL);
    mIndicatorColor = ta.getColor(R.styleable.SlidingTabLayout_tl_indicator_color, Color.parseColor(mIndicatorStyle == STYLE_BLOCK ? "#4B6A87" : "#ffffff"));
    mIndicatorHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_height,
            dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 4 : (mIndicatorStyle == STYLE_BLOCK ? -1 : 2)));
    mIndicatorWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_width, dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 10 : -1));
    mIndicatorCornerRadius = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_corner_radius, dp2px(mIndicatorStyle == STYLE_BLOCK ? -1 : 0));
    mIndicatorMarginLeft = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_left, dp2px(0));
    mIndicatorMarginTop = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_top, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
    mIndicatorMarginRight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_right, dp2px(0));
    mIndicatorMarginBottom = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_bottom, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
    mIndicatorGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_gravity, Gravity.BOTTOM);
    mIndicatorWidthEqualTitle = ta.getBoolean(R.styleable.SlidingTabLayout_tl_indicator_width_equal_title, false);

    mUnderlineColor = ta.getColor(R.styleable.SlidingTabLayout_tl_underline_color, Color.parseColor("#ffffff"));
    mUnderlineHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_underline_height, dp2px(0));
    mUnderlineGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_underline_gravity, Gravity.BOTTOM);

    mDividerColor = ta.getColor(R.styleable.SlidingTabLayout_tl_divider_color, Color.parseColor("#ffffff"));
    mDividerWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_width, dp2px(0));
    mDividerPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_padding, dp2px(12));

    mTextsize = ta.getDimension(R.styleable.SlidingTabLayout_tl_textsize, sp2px(14));
    mTextSelectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
    mTextUnselectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
    mTextBold = ta.getInt(R.styleable.SlidingTabLayout_tl_textBold, TEXT_BOLD_NONE);
    mTextAllCaps = ta.getBoolean(R.styleable.SlidingTabLayout_tl_textAllCaps, false);

    mTabSpaceEqual = ta.getBoolean(R.styleable.SlidingTabLayout_tl_tab_space_equal, false);
    mTabWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_width, dp2px(-1));
    mTabPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_padding, mTabSpaceEqual || mTabWidth > 0 ? dp2px(0) : dp2px(20));

    ta.recycle();
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:37,代码来源:SlidingTabLayout.java

示例11: obtainAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void obtainAttributes(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.LabelView);
    mTextContent = ta.getString(R.styleable.LabelView_lv_text);
    mTextColor = ta.getColor(R.styleable.LabelView_lv_text_color, Color.parseColor("#ffffff"));
    mTextSize = ta.getDimension(R.styleable.LabelView_lv_text_size, sp2px(11));
    mTextBold = ta.getBoolean(R.styleable.LabelView_lv_text_bold, true);
    mTextAllCaps = ta.getBoolean(R.styleable.LabelView_lv_text_all_caps, true);
    mFillTriangle = ta.getBoolean(R.styleable.LabelView_lv_fill_triangle, false);
    mBackgroundColor = ta.getColor(R.styleable.LabelView_lv_background_color, Color.parseColor("#FF4081"));
    mMinSize = ta.getDimension(R.styleable.LabelView_lv_min_size, mFillTriangle ? dp2px(35) : dp2px(50));
    mPadding = ta.getDimension(R.styleable.LabelView_lv_padding, dp2px(3.5f));
    mGravity = ta.getInt(R.styleable.LabelView_lv_gravity, Gravity.TOP | Gravity.LEFT);
    ta.recycle();
}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:15,代码来源:LabelView.java

示例12: DragScrollDetailsLayout

import android.content.res.TypedArray; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public DragScrollDetailsLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DragScrollDetailsLayout, defStyleAttr, 0);
    mPercent = a.getFloat(R.styleable.DragScrollDetailsLayout_percent, DEFAULT_PERCENT);
    mDuration = a.getInt(R.styleable.DragScrollDetailsLayout_duration, DEFAULT_DURATION);
    mDefaultPanel = a.getInt(R.styleable.DragScrollDetailsLayout_default_panel, 0);
    a.recycle();
    mScroller = new Scroller(getContext(), new DecelerateInterpolator());
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    mMaxFlingVelocity = ViewConfiguration.get(getContext()).getScaledMaximumFlingVelocity();
    mMiniFlingVelocity = ViewConfiguration.get(getContext()).getScaledMinimumFlingVelocity();
    setOrientation(VERTICAL);
}
 
开发者ID:longtaoge,项目名称:SelectName,代码行数:15,代码来源:DragScrollDetailsLayout.java

示例13: parseKeyboardAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void parseKeyboardAttributes(final XmlPullParser parser) {
    final AttributeSet attr = Xml.asAttributeSet(parser);
    final TypedArray keyboardAttr = mContext.obtainStyledAttributes(
            attr, R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard);
    final TypedArray keyAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard_Key);
    try {
        final KeyboardParams params = mParams;
        final int height = params.mId.mHeight;
        final int width = params.mId.mWidth;
        params.mOccupiedHeight = height;
        params.mOccupiedWidth = width;
        params.mTopPadding = (int)keyboardAttr.getFraction(
                R.styleable.Keyboard_keyboardTopPadding, height, height, 0);
        params.mBottomPadding = (int)keyboardAttr.getFraction(
                R.styleable.Keyboard_keyboardBottomPadding, height, height, 0);
        params.mLeftPadding = (int)keyboardAttr.getFraction(
                R.styleable.Keyboard_keyboardLeftPadding, width, width, 0);
        params.mRightPadding = (int)keyboardAttr.getFraction(
                R.styleable.Keyboard_keyboardRightPadding, width, width, 0);

        final int baseWidth =
                params.mOccupiedWidth - params.mLeftPadding - params.mRightPadding;
        params.mBaseWidth = baseWidth;
        params.mDefaultKeyWidth = (int)keyAttr.getFraction(R.styleable.Keyboard_Key_keyWidth,
                baseWidth, baseWidth, baseWidth / DEFAULT_KEYBOARD_COLUMNS);
        params.mHorizontalGap = (int)keyboardAttr.getFraction(
                R.styleable.Keyboard_horizontalGap, baseWidth, baseWidth, 0);
        // TODO: Fix keyboard geometry calculation clearer. Historically vertical gap between
        // rows are determined based on the entire keyboard height including top and bottom
        // paddings.
        params.mVerticalGap = (int)keyboardAttr.getFraction(
                R.styleable.Keyboard_verticalGap, height, height, 0);
        final int baseHeight = params.mOccupiedHeight - params.mTopPadding
                - params.mBottomPadding + params.mVerticalGap;
        params.mBaseHeight = baseHeight;
        params.mDefaultRowHeight = (int)ResourceUtils.getDimensionOrFraction(keyboardAttr,
                R.styleable.Keyboard_rowHeight, baseHeight, baseHeight / DEFAULT_KEYBOARD_ROWS);

        params.mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);

        params.mMoreKeysTemplate = keyboardAttr.getResourceId(
                R.styleable.Keyboard_moreKeysTemplate, 0);
        params.mMaxMoreKeysKeyboardColumn = keyAttr.getInt(
                R.styleable.Keyboard_Key_maxMoreKeysColumn, 5);

        params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0);
        params.mIconsSet.loadIcons(keyboardAttr);
        params.mTextsSet.setLocale(params.mId.getLocale(), mContext);
    } finally {
        keyAttr.recycle();
        keyboardAttr.recycle();
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:54,代码来源:KeyboardBuilder.java

示例14: MultiDirectionSlidingDrawer

import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
 * Creates a new SlidingDrawer from a specified set of attributes defined in
 * XML.
 *
 * @param context  The application's environment.
 * @param attrs    The attributes defined in XML.
 * @param defStyle The style to apply to this widget.
 */
public MultiDirectionSlidingDrawer(Context context, AttributeSet attrs,
                                   int defStyle) {
    super(context, attrs, defStyle);
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.MultiDirectionSlidingDrawer, defStyle, 0);

    int orientation = a.getInt(
            R.styleable.MultiDirectionSlidingDrawer_direction,
            ORIENTATION_BTT);
    mVertical = (orientation == ORIENTATION_BTT || orientation == ORIENTATION_TTB);
    mBottomOffset = (int) a.getDimension(
            R.styleable.MultiDirectionSlidingDrawer_bottomOffset, 0.0f);
    mTopOffset = (int) a.getDimension(
            R.styleable.MultiDirectionSlidingDrawer_topOffset, 0.0f);
    mAllowSingleTap = a.getBoolean(
            R.styleable.MultiDirectionSlidingDrawer_allowSingleTap, true);
    mAnimateOnClick = a.getBoolean(
            R.styleable.MultiDirectionSlidingDrawer_animateOnClick, true);
    mInvert = (orientation == ORIENTATION_TTB || orientation == ORIENTATION_LTR);

    int handleId = a.getResourceId(
            R.styleable.MultiDirectionSlidingDrawer_handle, 0);
    if (handleId == 0) {
        throw new IllegalArgumentException(
                "The handle attribute is required and must refer "
                        + "to a valid child.");
    }

    int contentId = a.getResourceId(
            R.styleable.MultiDirectionSlidingDrawer_content, 0);
    if (contentId == 0) {
        throw new IllegalArgumentException(
                "The content attribute is required and must refer "
                        + "to a valid child.");
    }

    if (handleId == contentId) {
        throw new IllegalArgumentException(
                "The content and handle attributes must refer "
                        + "to different children.");
    }
    mHandleId = handleId;
    mContentId = contentId;

    final float density = getResources().getDisplayMetrics().density;
    mTapThreshold = (int) (TAP_THRESHOLD * density + 0.5f);
    mMaximumTapVelocity = (int) (MAXIMUM_TAP_VELOCITY * density + 0.5f);
    mMaximumMinorVelocity = (int) (MAXIMUM_MINOR_VELOCITY * density + 0.5f);
    mMaximumMajorVelocity = (int) (MAXIMUM_MAJOR_VELOCITY * density + 0.5f);
    mMaximumAcceleration = (int) (MAXIMUM_ACCELERATION * density + 0.5f);
    mVelocityUnits = (int) (VELOCITY_UNITS * density + 0.5f);

    if (mInvert) {
        mMaximumAcceleration = -mMaximumAcceleration;
        mMaximumMajorVelocity = -mMaximumMajorVelocity;
        mMaximumMinorVelocity = -mMaximumMinorVelocity;
    }

    a.recycle();
    setAlwaysDrawnWithCacheEnabled(false);
}
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:70,代码来源:MultiDirectionSlidingDrawer.java

示例15: loadAttributes

import android.content.res.TypedArray; //导入方法依赖的package包/类
private void loadAttributes(Context context, AttributeSet attrs) {
    PADDING_5 = ScreenUtils.dp2PxInt(5);
    PADDING_12 = ScreenUtils.dp2PxInt(12);
    PADDING_15 = ScreenUtils.dp2PxInt(15);

    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CommonTitleBar);

    if (SysUtils.hasKitKat()) {
        // notice 未引入沉浸式标题栏之前,隐藏标题栏撑起布局
        fillStatusBar = array.getBoolean(R.styleable.CommonTitleBar_fillStatusBar, true);
    }
    titleBarColor = array.getColor(R.styleable.CommonTitleBar_titleBarColor, ContextCompat.getColor(context, R.color.ffffff_white_1000));
    titleBarHeight = (int) array.getDimension(R.styleable.CommonTitleBar_titleBarHeight, ScreenUtils.dp2PxInt(44));
    statusBarColor = array.getColor(R.styleable.CommonTitleBar_statusBarColor, ContextCompat.getColor(context, R.color.ffffff_white_1000));

    showBottomLine = array.getBoolean(R.styleable.CommonTitleBar_showBottomLine, true);
    bottomLineColor = array.getColor(R.styleable.CommonTitleBar_bottomLineColor, ContextCompat.getColor(context, R.color.dddddd_grey_350));
    bottomElevation = array.getDimension(R.styleable.CommonTitleBar_bottomElevation, ScreenUtils.dp2PxInt(5));

    leftType = array.getInt(R.styleable.CommonTitleBar_leftType, TYPE_LEFT_NONE);
    if (leftType == TYPE_LEFT_TEXTVIEW) {
        leftText = array.getString(R.styleable.CommonTitleBar_leftText);
        leftTextColor = array.getColor(R.styleable.CommonTitleBar_leftTextColor, ContextCompat.getColor(context, R.color.comm_titlebar_text_selector));
        leftTextSize = array.getDimension(R.styleable.CommonTitleBar_leftTextSize, ScreenUtils.sp2px(context, 16));
        leftDrawable = array.getResourceId(R.styleable.CommonTitleBar_leftDrawable, 0);
        leftDrawablePadding = array.getDimension(R.styleable.CommonTitleBar_leftDrawablePadding, 5);
    } else if (leftType == TYPE_LEFT_IMAGEBUTTON) {
        leftImageResource = array.getResourceId(R.styleable.CommonTitleBar_leftImageResource, R.drawable.comm_titlebar_reback_selector);
    } else if (leftType == TYPE_LEFT_CUSTOM_VIEW) {
        leftCustomViewRes = array.getResourceId(R.styleable.CommonTitleBar_leftCustomView, 0);
    }

    rightType = array.getInt(R.styleable.CommonTitleBar_rightType, TYPE_RIGHT_NONE);
    if (rightType == TYPE_RIGHT_TEXTVIEW) {
        rightText = array.getString(R.styleable.CommonTitleBar_rightText);
        rightTextColor = array.getColor(R.styleable.CommonTitleBar_rightTextColor, ContextCompat.getColor(context, R.color.comm_titlebar_text_selector));
        rightTextSize = array.getDimension(R.styleable.CommonTitleBar_rightTextSize, ScreenUtils.sp2px(context, 16));
    } else if (rightType == TYPE_RIGHT_IMAGEBUTTON) {
        rightImageResource = array.getResourceId(R.styleable.CommonTitleBar_rightImageResource, 0);
    } else if (rightType == TYPE_RIGHT_CUSTOM_VIEW) {
        rightCustomViewRes = array.getResourceId(R.styleable.CommonTitleBar_rightCustomView, 0);
    }

    centerType = array.getInt(R.styleable.CommonTitleBar_centerType, TYPE_CENTER_NONE);
    if (centerType == TYPE_CENTER_TEXTVIEW) {
        centerText = array.getString(R.styleable.CommonTitleBar_centerText);
        centerTextColor = array.getColor(R.styleable.CommonTitleBar_centerTextColor, ContextCompat.getColor(context, R.color.common_title_bar_center_text_color));
        centerTextSize = array.getDimension(R.styleable.CommonTitleBar_centerTextSize, ScreenUtils.sp2px(context, 18f));
        centerSubText = array.getString(R.styleable.CommonTitleBar_centerSubText);
        centerSubTextColor = array.getColor(R.styleable.CommonTitleBar_centerSubTextColor, ContextCompat.getColor(context, R.color._757575_grey_600));
        centerSubTextSize = array.getDimension(R.styleable.CommonTitleBar_centerSubTextSize, ScreenUtils.sp2px(context, 12));
    } else if (centerType == TYPE_CENTER_SEARCHVIEW) {
        centerSearchEdiable = array.getBoolean(R.styleable.CommonTitleBar_centerSearchEdiable, true);
        centerSearchBgResource = array.getResourceId(R.styleable.CommonTitleBar_centerSearchBg, R.drawable.comm_titlebar_search_gray_shape);
        centerSearchRightType = array.getInt(R.styleable.CommonTitleBar_centerSearchRightType, TYPE_CENTER_SEARCH_RIGHT_VOICE);
    } else if (centerType == TYPE_CENTER_CUSTOM_VIEW) {
        centerCustomViewRes = array.getResourceId(R.styleable.CommonTitleBar_centerCustomView, 0);
    }

    array.recycle();
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:62,代码来源:CommonTitleBar.java


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