当前位置: 首页>>代码示例>>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;未经允许,请勿转载。