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


Java Theme類代碼示例

本文整理匯總了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;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:29,代碼來源:FoldableLinearLayout.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:sfilmak,項目名稱:MakiLite,代碼行數:17,代碼來源:ThemeUtils.java

示例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());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:DrawableDecoderCompat.java

示例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);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:22,代碼來源:JarMainBFragmentActivity.java

示例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);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:ToolbarActionBar.java

示例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();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:AppCompatDelegateImplV7.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:34,代碼來源:AppCompatDelegateImplV7.java

示例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);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:AppCompatSpinner.java

示例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;
}
 
開發者ID:XhinLiang,項目名稱:MDPreference,代碼行數:17,代碼來源:ThemeUtils.java

示例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);
        }
    }
}
 
開發者ID:Qwaz,項目名稱:solved-hacking-problem,代碼行數:21,代碼來源:bi.java

示例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);
    }
}
 
開發者ID:canyinghao,項目名稱:CanDialog,代碼行數:26,代碼來源:VectorDrawable.java

示例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();
        }
    }
}
 
開發者ID:freeotp,項目名稱:freeotp-android,代碼行數:26,代碼來源:ProgressCircle.java

示例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();
}
 
開發者ID:Qwaz,項目名稱:solved-hacking-problem,代碼行數:23,代碼來源:aq.java

示例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;
	}
}
 
開發者ID:LifengMr,項目名稱:apker,代碼行數:17,代碼來源:JarMainBaseActivity.java

示例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);
            }
        }
    }
}
 
開發者ID:canyinghao,項目名稱:CanDialog,代碼行數:21,代碼來源:VectorDrawable.java


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