本文整理汇总了Java中android.content.res.Resources.Theme类的典型用法代码示例。如果您正苦于以下问题:Java Theme类的具体用法?Java Theme怎么用?Java Theme使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Theme类属于android.content.res.Resources包,在下文中一共展示了Theme类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processAttributes
import android.content.res.Resources.Theme; //导入依赖的package包/类
/**
* Load given attributes to inner variables,
*
* @param context
* @param attrs
*/
private void processAttributes(Context context, AttributeSet attrs) {
Theme theme = context.getTheme();
TypedValue outValue = new TypedValue();
boolean found = theme.resolveAttribute(R.attr.iconActionCollapse, outValue, true);
if (found) {
mIconActionCollapseId = outValue.resourceId;
}
found = theme.resolveAttribute(R.attr.iconActionExpand, outValue, true);
if (found) {
mIconActionExpandId = outValue.resourceId;
}
if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.FoldableLinearLayout, 0, 0);
mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel);
mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel);
a.recycle();
}
// If any attribute isn't found then set a default one
mFoldedLabel = (mFoldedLabel == null) ? "No text!" : mFoldedLabel;
mUnFoldedLabel = (mUnFoldedLabel == null) ? "No text!" : mUnFoldedLabel;
}
示例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;
}
示例3: getDrawable
import android.content.res.Resources.Theme; //导入依赖的package包/类
/**
* Loads a Drawable using {@link AppCompatResources} if available and {@link ResourcesCompat}
* otherwise, depending on whether or not the v7 support library is included in the application.
*
* @param theme Used instead of the {@link Theme} returned from the given {@link Context} if
* non-null when loading the {@link Drawable}.
*/
public static Drawable getDrawable(Context context, @DrawableRes int id, @Nullable Theme theme) {
try {
// Race conditions may cause us to attempt to load using v7 more than once. That's ok since
// this check is a modest optimization and the output will be correct anyway.
if (shouldCallAppCompatResources) {
return loadDrawableV7(context, id);
}
} catch (NoClassDefFoundError error) {
shouldCallAppCompatResources = false;
} catch (Resources.NotFoundException e) {
// Ignored, this can be thrown when drawable compat attempts to decode a canary resource. If
// that decode attempt fails, we still want to try with the v4 ResourcesCompat below.
}
return loadDrawableV4(context, id, theme != null ? theme : context.getTheme());
}
示例4: setOverrideResources
import android.content.res.Resources.Theme; //导入依赖的package包/类
public void setOverrideResources(JarResources myres) {
JLog.i("clf", "setOverrideResources...myres=" + myres);
if (myres == null) {
this.myResources = null;
this.resources = null;
this.assetManager = null;
this.theme = null;
return;
}
this.myResources = myres;
JLog.i("clf", "setOverrideResources...this.myResources=" + this.myResources);
this.resources = myres.getResources();
JLog.i("clf", "setOverrideResources...this.resources=" + this.resources);
this.assetManager = myres.getAssets();
JLog.i("clf", "setOverrideResources...this.assetManager=" + this.assetManager);
Theme t = myres.getResources().newTheme();
JLog.i("clf", "setOverrideResources...t=" + t);
t.setTo(getTheme());
this.theme = t;
JLog.i("clf", "setOverrideResources...this.theme=" + this.theme);
}
示例5: ensureListMenuPresenter
import android.content.res.Resources.Theme; //导入依赖的package包/类
private void ensureListMenuPresenter(Menu menu) {
if (this.mListMenuPresenter == null && (menu instanceof MenuBuilder)) {
MenuBuilder mb = (MenuBuilder) menu;
Context context = this.mDecorToolbar.getContext();
TypedValue outValue = new TypedValue();
Theme widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(context.getTheme());
widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme, outValue, true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId, true);
}
widgetTheme.resolveAttribute(R.attr.panelMenuListTheme, outValue, true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId, true);
} else {
widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true);
}
Context context2 = new ContextThemeWrapper(context, 0);
context2.getTheme().setTo(widgetTheme);
this.mListMenuPresenter = new ListMenuPresenter(context2, R.layout.abc_list_menu_item_layout);
this.mListMenuPresenter.setCallback(new PanelMenuPresenterCallback());
mb.addMenuPresenter(this.mListMenuPresenter);
}
}
示例6: setStyle
import android.content.res.Resources.Theme; //导入依赖的package包/类
void setStyle(Context context) {
TypedValue outValue = new TypedValue();
Theme widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(context.getTheme());
widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme, outValue, true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId, true);
}
widgetTheme.resolveAttribute(R.attr.panelMenuListTheme, outValue, true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId, true);
} else {
widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true);
}
Context context2 = new ContextThemeWrapper(context, 0);
context2.getTheme().setTo(widgetTheme);
this.listPresenterContext = context2;
TypedArray a = context2.obtainStyledAttributes(R.styleable.AppCompatTheme);
this.background = a.getResourceId(R.styleable.AppCompatTheme_panelBackground, 0);
this.windowAnimations = a.getResourceId(R.styleable.AppCompatTheme_android_windowAnimationStyle, 0);
a.recycle();
}
示例7: initializePanelMenu
import android.content.res.Resources.Theme; //导入依赖的package包/类
private boolean initializePanelMenu(PanelFeatureState st) {
Context context = this.mContext;
if ((st.featureId == 0 || st.featureId == 108) && this.mDecorContentParent != null) {
TypedValue outValue = new TypedValue();
Theme baseTheme = context.getTheme();
baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
Theme widgetTheme = null;
if (outValue.resourceId != 0) {
widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(baseTheme);
widgetTheme.applyStyle(outValue.resourceId, true);
widgetTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
} else {
baseTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
}
if (outValue.resourceId != 0) {
if (widgetTheme == null) {
widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(baseTheme);
}
widgetTheme.applyStyle(outValue.resourceId, true);
}
if (widgetTheme != null) {
Context context2 = new ContextThemeWrapper(context, 0);
context2.getTheme().setTo(widgetTheme);
context = context2;
}
}
MenuBuilder menu = new MenuBuilder(context);
menu.setCallback(this);
st.setMenu(menu);
return true;
}
示例8: DropDownAdapter
import android.content.res.Resources.Theme; //导入依赖的package包/类
public DropDownAdapter(@Nullable SpinnerAdapter adapter, @Nullable Theme dropDownTheme) {
this.mAdapter = adapter;
if (adapter instanceof ListAdapter) {
this.mListAdapter = (ListAdapter) adapter;
}
if (dropDownTheme == null) {
return;
}
if (AppCompatSpinner.IS_AT_LEAST_M && (adapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedAdapter = (ThemedSpinnerAdapter) adapter;
if (themedAdapter.getDropDownViewTheme() != dropDownTheme) {
themedAdapter.setDropDownViewTheme(dropDownTheme);
}
} else if (adapter instanceof ThemedSpinnerAdapter) {
ThemedSpinnerAdapter themedAdapter2 = (ThemedSpinnerAdapter) adapter;
if (themedAdapter2.getDropDownViewTheme() == null) {
themedAdapter2.setDropDownViewTheme(dropDownTheme);
}
}
}
示例9: 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;
}
示例10: bi
import android.content.res.Resources.Theme; //导入依赖的package包/类
public bi(SpinnerAdapter spinnerAdapter, Theme theme) {
this.f1367a = spinnerAdapter;
if (spinnerAdapter instanceof ListAdapter) {
this.f1368b = (ListAdapter) spinnerAdapter;
}
if (theme == null) {
return;
}
if (bg.f1353a && (spinnerAdapter instanceof ThemedSpinnerAdapter)) {
ThemedSpinnerAdapter themedSpinnerAdapter = (ThemedSpinnerAdapter) spinnerAdapter;
if (themedSpinnerAdapter.getDropDownViewTheme() != theme) {
themedSpinnerAdapter.setDropDownViewTheme(theme);
}
} else if (spinnerAdapter instanceof dd) {
dd ddVar = (dd) spinnerAdapter;
if (ddVar.m2705a() == null) {
ddVar.m2706a(theme);
}
}
}
示例11: applyTheme
import android.content.res.Resources.Theme; //导入依赖的package包/类
@Override
public void applyTheme(Theme t) {
super.applyTheme(t);
final VectorDrawableState state = mVectorState;
if (state != null && state.mThemeAttrs != null) {
//TODO
final TypedArray a = null;//t.resolveAttributes(state.mThemeAttrs, R.styleable.VectorDrawable);
try {
state.mCacheDirty = true;
updateStateFromTypedArray(a);
} catch (XmlPullParserException e) {
throw new RuntimeException(e);
} finally {
a.recycle();
}
mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
}
final VPathRenderer path = state.mVPathRenderer;
if (path != null && path.canApplyTheme()) {
path.applyTheme(t);
}
}
示例12: 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();
}
}
}
示例13: m1771a
import android.content.res.Resources.Theme; //导入依赖的package包/类
void m1771a(Context context) {
TypedValue typedValue = new TypedValue();
Theme newTheme = context.getResources().newTheme();
newTheme.setTo(context.getTheme());
newTheme.resolveAttribute(C0233b.actionBarPopupTheme, typedValue, true);
if (typedValue.resourceId != 0) {
newTheme.applyStyle(typedValue.resourceId, true);
}
newTheme.resolveAttribute(C0233b.panelMenuListTheme, typedValue, true);
if (typedValue.resourceId != 0) {
newTheme.applyStyle(typedValue.resourceId, true);
} else {
newTheme.applyStyle(C0242k.Theme_AppCompat_CompactMenu, true);
}
Context c0249e = new C0249e(context, 0);
c0249e.getTheme().setTo(newTheme);
this.f646l = c0249e;
TypedArray obtainStyledAttributes = c0249e.obtainStyledAttributes(C0243l.AppCompatTheme);
this.f636b = obtainStyledAttributes.getResourceId(C0243l.AppCompatTheme_panelBackground, 0);
this.f640f = obtainStyledAttributes.getResourceId(C0243l.AppCompatTheme_android_windowAnimationStyle, 0);
obtainStyledAttributes.recycle();
}
示例14: setOverrideResources
import android.content.res.Resources.Theme; //导入依赖的package包/类
@Override
public void setOverrideResources(ApkResources myres) {
if (myres == null) {
this.jarResources = null;
this.resources = null;
this.assetManager = null;
this.theme = null;
} else {
this.jarResources = myres;
this.resources = myres.getResources();
this.assetManager = myres.getAssets();
Theme t = myres.getResources().newTheme();
t.setTo(getTheme());
this.theme = t;
}
}
示例15: recursiveApplyTheme
import android.content.res.Resources.Theme; //导入依赖的package包/类
private void recursiveApplyTheme(VGroup currentGroup, Theme t) {
// We can do a tree traverse here, apply theme to all paths which
// can apply theme.
final ArrayList<Object> children = currentGroup.mChildren;
for (int i = 0; i < children.size(); i++) {
Object child = children.get(i);
if (child instanceof VGroup) {
VGroup childGroup = (VGroup) child;
if (childGroup.canApplyTheme()) {
childGroup.applyTheme(t);
}
recursiveApplyTheme(childGroup, t);
} else if (child instanceof VPath) {
VPath childPath = (VPath) child;
if (childPath.canApplyTheme()) {
childPath.applyTheme(t);
}
}
}
}