當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。