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


Java Context.obtainStyledAttributes方法代码示例

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


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

示例1: obtainMutableAttrList

import android.content.Context; //导入方法依赖的package包/类
/**
 * 通过传入的属性,获取支持的自定义属性MutableAttr列表
 * @param context
 * @param attrs
 * @return
 */
public List<MutableAttr> obtainMutableAttrList(Context context, AttributeSet attrs, List<MutableAttr> viewAttrs) {
    if (mCustomAttrList == null || mCustomAttrList.isEmpty()) {
        return new ArrayList<>();
    }
    if (viewAttrs == null) {
        viewAttrs = new ArrayList<>();
    }
    Collections.sort(mCustomAttrList);
    int size = mCustomAttrList.size();
    int[] customAttrs = new int[size];
    for (int i = 0; i < size; i++) {
        customAttrs[i] = mCustomAttrList.get(i);
    }
    TypedArray a = context.obtainStyledAttributes(attrs, customAttrs);
    int N = a.getIndexCount();
    for (int j = 0; j < N; j++) {
        int index = a.getIndex(j);
        int resId = a.getResourceId(index, 0);
        MutableAttr mutableAttr = MutableAttrFactory.create(context, customAttrs[j], resId);
        if (mutableAttr != null) {
            viewAttrs.add(mutableAttr);
        }
    }
    return viewAttrs;
}
 
开发者ID:MeetYouDevs,项目名称:Android-Skin,代码行数:32,代码来源:CustomAttrManager.java

示例2: Rotate3dAnimation

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

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Rotate3dAnimation);

    mFromDegrees = a.getFloat(R.styleable.Rotate3dAnimation_fromDeg, 0.0f);
    mToDegrees = a.getFloat(R.styleable.Rotate3dAnimation_toDeg, 0.0f);
    mRollType = a.getInt(R.styleable.Rotate3dAnimation_rollType, ROLL_BY_X);
    Description d = parseValue(a.peekValue(R.styleable.Rotate3dAnimation_pivotX));
    mPivotXType = d.type;
    mPivotXValue = d.value;

    d = parseValue(a.peekValue(R.styleable.Rotate3dAnimation_pivotY));
    mPivotYType = d.type;
    mPivotYValue = d.value;

    a.recycle();

    initializePivotPoint();
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:21,代码来源:Rotate3dAnimation.java

示例3: initAttrs

import android.content.Context; //导入方法依赖的package包/类
private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr) {
    mCircleRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, mMetrics);
    mSpaceRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, mMetrics);
    mAnnulusWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, mMetrics);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RadarView, defStyleAttr, 0);
    mRadarColor = a.getColor(R.styleable.RadarView_radarview_radarColor, Color.GRAY);
    mCircleRadius = a.getDimension(R.styleable.RadarView_radarview_circleRadius, mCircleRadius);
    mSpaceRadius = a.getDimension(R.styleable.RadarView_radarview_spaceRadius, mSpaceRadius);
    mAnnulusNum = a.getInt(R.styleable.RadarView_radarview_annulusNum, mAnnulusNum);
    mAnnulusWidth = a.getDimension(R.styleable.RadarView_radarview_annulusWidth, mAnnulusWidth);
    mAnnulusColor = a.getColor(R.styleable.RadarView_radarview_annulusColor, Color.GRAY);
    int rotateRateIndex = a.getInt(R.styleable.RadarView_radarview_rotateRate, 1);
    switch (rotateRateIndex) {
        case 0:
            mRotateRate = RotateRate.SLOW;
            break;
        case 1:
            mRotateRate = RotateRate.FAST;
            break;
    }
    mReverse = a.getBoolean(R.styleable.RadarView_radarview_reverse, false);
    a.recycle();
}
 
开发者ID:JackWHLiu,项目名称:jackknife,代码行数:24,代码来源:RadarView.java

示例4: SnackbarBaseLayout

import android.content.Context; //导入方法依赖的package包/类
SnackbarBaseLayout(Context context, AttributeSet attrs) {
  super(context, attrs);
  TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnackbarLayout);
        if (a.hasValue(R.styleable.SnackbarLayout_android_elevation)) {
            ViewCompat.setElevation(this, a.getDimensionPixelSize(
                    R.styleable.SnackbarLayout_android_elevation, 0));
  }
  a.recycle();

  setClickable(true);
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:12,代码来源:BaseTransientBottomBar.java

示例5: setup

import android.content.Context; //导入方法依赖的package包/类
private void setup(Context context, AttributeSet attrs) {
    setDialogLayoutResource(R.layout.slider_preference_dialog);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SliderPreference);
    try {
        setSummary(a.getTextArray(R.styleable.SliderPreference_android_summary));
    } catch (Exception e) {
        // Do nothing
    }
    a.recycle();
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:11,代码来源:SliderPreference.java

示例6: RImageView

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

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RImageView);
    mMaskDrawable = typedArray.getDrawable(R.styleable.RImageView_r_mask_drawable);
    maskGravity = typedArray.getInt(R.styleable.RImageView_r_mask_gravity, maskGravity);
    maskScaleX = typedArray.getFloat(R.styleable.RImageView_r_mask_scale_x, maskScaleX);
    maskScaleY = typedArray.getFloat(R.styleable.RImageView_r_mask_scale_y, maskScaleY);
    typedArray.recycle();
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:12,代码来源:RImageView.java

示例7: SolidLayout

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

    if (attrs != null) {
        final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SolidLayout, 0, 0);
        mPreventParentTouchEvents = a.getBoolean(R.styleable.SolidLayout_preventParentTouchEvents, mPreventParentTouchEvents);
        mPreventChildTouchEvents = a.getBoolean(R.styleable.SolidLayout_preventChildTouchEvents, mPreventChildTouchEvents);
        a.recycle();
    }
}
 
开发者ID:tranleduy2000,项目名称:floating_calc,代码行数:11,代码来源:SolidLayout.java

示例8: DStateLayout

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

  mInflater = LayoutInflater.from(context);
  TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DStateLayout, defStyleAttr,
      R.style.DStateLayout_Style);
  mEmptyImage = a.getResourceId(R.styleable.DStateLayout_llEmptyImage, NO_ID);
  mEmptyText = a.getString(R.styleable.DStateLayout_llEmptyText);

  mErrorImage = a.getResourceId(R.styleable.DStateLayout_llErrorImage, NO_ID);
  mErrorText = a.getString(R.styleable.DStateLayout_llErrorText);
  mRetryText = a.getString(R.styleable.DStateLayout_llRetryText);

  mTextColor = a.getColor(R.styleable.DStateLayout_llTextColor, 0xff999999);
  mTextSize = a.getDimensionPixelSize(R.styleable.DStateLayout_llTextSize, dp2px(16));

  mButtonTextColor = a.getColor(R.styleable.DStateLayout_llButtonTextColor, 0xff999999);
  mButtonTextSize = a.getDimensionPixelSize(R.styleable.DStateLayout_llButtonTextSize, dp2px(16));
  mButtonBackground = a.getDrawable(R.styleable.DStateLayout_llButtonBackground);

  mEmptyResId =
      a.getResourceId(R.styleable.DStateLayout_llEmptyResId, R.layout.d_state_layout_empty);
  mLoadingResId =
      a.getResourceId(R.styleable.DStateLayout_llLoadingResId, R.layout.d_state_layout_loading);
  mErrorResId =
      a.getResourceId(R.styleable.DStateLayout_llErrorResId, R.layout.d_state_layout_error);
  a.recycle();
}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:29,代码来源:DStateLayout.java

示例9: init

import android.content.Context; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ColorIconView);
    int color = typedArray.getColor(R.styleable.ColorIconView_civ_color, 0);

    setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
    typedArray.recycle();
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:8,代码来源:ColorIconView.java

示例10: init

import android.content.Context; //导入方法依赖的package包/类
public void init(Context context, AttributeSet attrs) {
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ClipViewLayout);

    //获取剪切框距离左右的边距, 默认为50dp
    mHorizontalPadding = array.getDimensionPixelSize(R.styleable.ClipViewLayout_mHorizontalPadding,
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics()));
    //获取裁剪框边框宽度,默认1dp
    int clipBorderWidth = array.getDimensionPixelSize(R.styleable.ClipViewLayout_clipBorderWidth,
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    //裁剪框类型(圆或者矩形)
    int clipType = array.getInt(R.styleable.ClipViewLayout_clipType, 1);

    //回收
    array.recycle();
    clipView = new ClipView(context);
    //设置裁剪框类型
    clipView.setClipType(clipType == 1 ? ClipView.ClipType.CIRCLE : ClipView.ClipType.RECTANGLE);
    //设置剪切框边框
    clipView.setClipBorderWidth(clipBorderWidth);
    //设置剪切框水平间距
    clipView.setmHorizontalPadding(mHorizontalPadding);
    imageView = new ImageView(context);
    //相对布局布局参数
    android.view.ViewGroup.LayoutParams lp = new LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.MATCH_PARENT);
    this.addView(imageView, lp);
    this.addView(clipView, lp);
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:30,代码来源:ClipViewLayout.java

示例11: VideoControlView

import android.content.Context; //导入方法依赖的package包/类
public VideoControlView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.VideoControlView);
        int itemColor = ta.getColor(R.styleable.VideoControlView_itemColor, DEFAULT_ITEM_COLOR);
        ta.recycle();
//        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setColor(itemColor);

        mPath = new Path();
        mDuration = DEFAULT_DURATION;
    }
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:14,代码来源:VideoControlView.java

示例12: init

import android.content.Context; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs)
{
    setWillNotDraw(false);
    initEffectBridge();
    // 初始化.
    if (attrs != null)
    {
        TypedArray tArray = context.obtainStyledAttributes(attrs, R.styleable.MainUpView);// 获取配置属性
        Drawable drawableUpRect = tArray.getDrawable(R.styleable.MainUpView_upImageRes); // 顶层图片.
        Drawable drawableShadow = tArray.getDrawable(R.styleable.MainUpView_shadowImageRes); // 阴影图片.
        setUpRectDrawable(drawableUpRect);
        setShadowDrawable(drawableShadow);
        tArray.recycle();
    }
}
 
开发者ID:Dreamxiaoxuan,项目名称:AndroidTvDemo,代码行数:16,代码来源:MainUpView.java

示例13: checkAppCompatTheme

import android.content.Context; //导入方法依赖的package包/类
public static void checkAppCompatTheme(Context context) {
    TypedArray a = context.obtainStyledAttributes(APPCOMPAT_CHECK_ATTRS);
    final boolean failed = !a.hasValue(0);
    a.recycle();
    if (failed) {
        throw new IllegalArgumentException("You need to use a Theme.AppCompat theme "
                + "(or descendant) with the design library.");
    }
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:10,代码来源:QMUIViewHelper.java

示例14: IReaderGridLayout

import android.content.Context; //导入方法依赖的package包/类
public IReaderGridLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IReaderGridLayout, defStyleAttr, 0);
    mRowCount = a.getInt(R.styleable.IReaderGridLayout_iReaderRowCount, 2);
    mColumnCount = a.getInt(R.styleable.IReaderGridLayout_iReaderColumnCount, 2);
    mGap = a.getDimensionPixelSize(R.styleable.IReaderGridLayout_iReaderGap, 0);
    a.recycle();
}
 
开发者ID:AlphaBoom,项目名称:ClassifyView,代码行数:9,代码来源:IReaderGridLayout.java

示例15: SettingItemView

import android.content.Context; //导入方法依赖的package包/类
public SettingItemView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SettingItemView);
    this.mIcon = typedArray.getDrawable(1);
    this.mTitle = typedArray.getString(2);
    this.mSubTitle = typedArray.getString(3);
    this.mTextIndicator = typedArray.getString(4);
    this.mTopDivider = typedArray.getBoolean(0, false);
    this.mBottomDivider = typedArray.getBoolean(5, false);
    typedArray.recycle();
    this.mView = LayoutInflater.from(getContext()).inflate(R.layout.qp, null);
    addView(this.mView);
    ButterKnife.inject((View) this);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:SettingItemView.java


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