當前位置: 首頁>>代碼示例>>Java>>正文


Java Theme.obtainStyledAttributes方法代碼示例

本文整理匯總了Java中android.content.res.Resources.Theme.obtainStyledAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Java Theme.obtainStyledAttributes方法的具體用法?Java Theme.obtainStyledAttributes怎麽用?Java Theme.obtainStyledAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources.Theme的用法示例。


在下文中一共展示了Theme.obtainStyledAttributes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resolveAccentColor

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
@TargetApi(LOLLIPOP)
static int resolveAccentColor(Context context) {
  Theme theme = context.getTheme();

  // on Lollipop, grab system colorAccent attribute
  // pre-Lollipop, grab AppCompat colorAccent attribute
  // finally, check for custom mp_colorAccent attribute
  int attr = isAtLeastL() ? android.R.attr.colorAccent : R.attr.colorAccent;
  TypedArray typedArray = theme.obtainStyledAttributes(new int[] { attr, R.attr.mp_colorAccent });

  int accentColor = typedArray.getColor(0, FALLBACK_COLOR);
  accentColor = typedArray.getColor(1, accentColor);
  typedArray.recycle();

  return accentColor;
}
 
開發者ID:sfilmak,項目名稱:MakiLite,代碼行數:17,代碼來源:ThemeUtils.java

示例2: resolveAccentColor

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
@TargetApi(LOLLIPOP)
static int resolveAccentColor(Context context) {
    Theme theme = context.getTheme();

    // on Lollipop, grab system colorAccent attribute
    // pre-Lollipop, grab AppCompat colorAccent attribute
    // finally, check for custom mp_colorAccent attribute
    int attr = isAtLeastL() ? android.R.attr.colorAccent : R.attr.colorAccent;
    TypedArray typedArray = theme.obtainStyledAttributes(new int[]{attr, R.attr.mp_colorAccent});

    int accentColor = typedArray.getColor(0, FALLBACK_COLOR);
    accentColor = typedArray.getColor(1, accentColor);
    typedArray.recycle();

    return accentColor;
}
 
開發者ID:XhinLiang,項目名稱:MDPreference,代碼行數:17,代碼來源:ThemeUtils.java

示例3: setup

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
private void setup(Context context, AttributeSet attrs) {
    DisplayMetrics dm = getResources().getDisplayMetrics();
    mPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, dm);
    mStrokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, dm);

    mRectF = new RectF();
    mRect = new Rect();

    mPaint = new Paint();
    mPaint.setARGB(0x99, 0x33, 0x33, 0x33);
    mPaint.setAntiAlias(true);
    mPaint.setStrokeCap(Paint.Cap.BUTT);

    if (attrs != null) {
        Theme t = context.getTheme();
        TypedArray a = t.obtainStyledAttributes(attrs, R.styleable.ProgressCircle, 0, 0);

        try {
            setMax(a.getInteger(R.styleable.ProgressCircle_max, 100));
            setHollow(a.getBoolean(R.styleable.ProgressCircle_hollow, false));
        } finally {
            a.recycle();
        }
    }
}
 
開發者ID:freeotp,項目名稱:freeotp-android,代碼行數:26,代碼來源:ProgressCircle.java

示例4: applyPreloaderTheme

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
public void applyPreloaderTheme(Theme t) {
    TypedArray ta = t.obtainStyledAttributes(R.styleable.PreloadIconDrawable);
    mBgDrawable = ta.getDrawable(R.styleable.PreloadIconDrawable_background);
    mBgDrawable.setFilterBitmap(true);
    mPaint.setStrokeWidth(ta.getDimension(R.styleable.PreloadIconDrawable_indicatorSize, 0));
    mRingOutset = ta.getDimensionPixelSize(R.styleable.PreloadIconDrawable_ringOutset, 0);
    ta.recycle();
    onBoundsChange(getBounds());
    invalidateSelf();
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:11,代碼來源:PreloadIconDrawable.java

示例5: getThemeAttributeColor

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
public static int getThemeAttributeColor(Context context, int attr) {
    TypedArray a = null;
    try {
        Theme theme = context.getTheme();
        int[] iArr = new int[COLOR_DEFAULT];
        iArr[0] = attr;
        a = theme.obtainStyledAttributes(iArr);
        int color = a.getColor(0, 0);
        return color;
    } finally {
        if (a != null) {
            a.recycle();
        }
    }
}
 
開發者ID:mrprona92,項目名稱:SecretBrand,代碼行數:16,代碼來源:Utils.java

示例6: setValue

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void setValue(Theme newTheme, int themeId) {
    if (mView == null) {
        return;
    }
    TypedArray a = newTheme.obtainStyledAttributes(themeId,
            new int[]{mAttrResId});
    int attributeResourceId = a.getResourceId(0, 0);
    Drawable drawable = mView.getResources().getDrawable(
            attributeResourceId);
    a.recycle();
    mView.setBackgroundDrawable(drawable);
}
 
開發者ID:liuhui19991,項目名稱:CloudMusicLH,代碼行數:15,代碼來源:ViewBackgroundDrawableSetter.java

示例7: setValue

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void setValue(Theme newTheme, int themeId) {
	if ( mView == null ) {
		return  ;
	}
	TypedArray a = newTheme.obtainStyledAttributes(themeId,
			new int[] { mAttrResId });
	int attributeResourceId = a.getResourceId(0, 0);
	Drawable drawable = mView.getResources().getDrawable(
			attributeResourceId);
	a.recycle();
	mView.setBackgroundDrawable(drawable);
}
 
開發者ID:CarpOrange,項目名稱:CloudMusic,代碼行數:15,代碼來源:ViewBackgroundDrawableSetter.java

示例8: getToolbarHeight

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
/**
 * Retrieves the toolbar height of the current app theme.
 *
 * @param theme the device {@link Theme}
 * @param actionBarSize the current {@link ActionBar} size
 * @return the toolbar height of the current app theme
 */
@Dimension(unit = Dimension.DP)
public static int getToolbarHeight(@NonNull Theme theme, @AttrRes int actionBarSize) {
  final TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] {actionBarSize});
  int toolbarHeight = (int) styledAttributes.getDimension(0, 0);
  styledAttributes.recycle();
  return toolbarHeight;
}
 
開發者ID:xmartlabs,項目名稱:bigbang,代碼行數:15,代碼來源:MetricsHelper.java

示例9: getThemeColor

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
public static int getThemeColor(Context context, int id) {
    Theme theme = context.getTheme();
    TypedArray a = theme.obtainStyledAttributes(new int[]{id});
    int result = a.getColor(0, DEFAULT_COLOR);
    a.recycle();
    return result;
}
 
開發者ID:goodev,項目名稱:materialup,代碼行數:8,代碼來源:ThemeUtil.java

示例10: getThemeDark

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
public static boolean getThemeDark(Context context, int id) {
    Theme theme = context.getTheme();
    TypedArray a = theme.obtainStyledAttributes(new int[]{id});
    boolean result = a.getBoolean(0, false);
    a.recycle();
    return result;
}
 
開發者ID:goodev,項目名稱:materialup,代碼行數:8,代碼來源:ThemeUtil.java

示例11: getThemeDrawable

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
public static Drawable getThemeDrawable(Context context, int res) {
    Theme theme = context.getTheme();
    TypedArray a = theme.obtainStyledAttributes(new int[]{res});
    Drawable result = a.getDrawable(0);
    a.recycle();
    return result;
}
 
開發者ID:goodev,項目名稱:droidddle,代碼行數:8,代碼來源:ThemeUtil.java

示例12: resolveAccentColor

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
@SuppressWarnings("ResourceType")
@TargetApi(LOLLIPOP)
public static int resolveAccentColor(Context context) {
  Theme theme = context.getTheme();


  int attr = isAtLeastL() ? android.R.attr.colorAccent : R.attr.colorAccent;
  TypedArray typedArray = theme.obtainStyledAttributes(new int[] { attr, R.attr.mp_colorAccent });

  int accentColor = typedArray.getColor(0, FALLBACK_COLOR);
  accentColor = typedArray.getColor(1, accentColor);
  typedArray.recycle();

  return accentColor;
}
 
開發者ID:creativetrendsapps,項目名稱:SimplicityBrowser,代碼行數:16,代碼來源:ThemeUtils.java

示例13: getColor

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
/**
 * Returns color for attr from the {@link Theme}
 *
 * @param theme {@link Theme} to get int from
 * @param attr  Attribute of the int
 * @return dimension for attr from the {@link Theme}
 */
@ColorInt
public static int getColor(@NonNull final Theme theme, @AttrRes final int attr) {
    final TypedArray array = theme.obtainStyledAttributes(new int[]{attr});
    try {
        return array.getColor(0, Color.TRANSPARENT);
    } finally {
        array.recycle();
    }
}
 
開發者ID:Doctoror,項目名稱:PainlessMusicPlayer,代碼行數:17,代碼來源:ThemeUtils.java

示例14: getColorStateList

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
/**
 * Returns {@link ColorStateList} for attr from the {@link Theme}
 *
 * @param theme {@link Theme} to get int from
 * @param attr  Attribute of the int
 * @return dimension for attr from the {@link Theme}
 */
@Nullable
public static ColorStateList getColorStateList(@NonNull final Theme theme,
        @AttrRes final int attr) {
    final TypedArray array = theme.obtainStyledAttributes(new int[]{attr});
    try {
        return array.getColorStateList(0);
    } finally {
        array.recycle();
    }
}
 
開發者ID:Doctoror,項目名稱:PainlessMusicPlayer,代碼行數:18,代碼來源:ThemeUtils.java

示例15: obtainAttributes

import android.content.res.Resources.Theme; //導入方法依賴的package包/類
static TypedArray obtainAttributes(Resources res, Theme theme, AttributeSet set, int[] attrs) {
    if (theme == null) {
        return res.obtainAttributes(set, attrs);
    }
    return theme.obtainStyledAttributes(set, attrs, 0, 0);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:7,代碼來源:VectorDrawableCommon.java


注:本文中的android.content.res.Resources.Theme.obtainStyledAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。