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


Java Resources.Theme方法代碼示例

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


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

示例1: getDefaultTextAttribute

import android.content.res.Resources; //導入方法依賴的package包/類
private static ColorStateList getDefaultTextAttribute(Context context, int attribute) {
  Resources.Theme theme = context.getTheme();
  TypedArray textAppearances = null;
  try {
    textAppearances = theme.obtainStyledAttributes(new int[]{attribute});
    ColorStateList textColor = textAppearances.getColorStateList(0);
    return textColor;
  } finally {
    if (textAppearances != null) {
      textAppearances.recycle();
    }
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:14,代碼來源:DefaultStyleValuesUtil.java

示例2: onApplyThemeResource

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
protected void onApplyThemeResource(Resources.Theme theme, @StyleRes int resid,
                                    boolean first) {
    if (mParent == null) {
        super.onApplyThemeResource(theme, resid, first);
    } else {
        try {
            theme.setTo(mParent.getTheme());
        } catch (Exception e) {
            // Empty
        }
        theme.applyStyle(resid, false);
    }

    // Get the primary color and update the TaskDescription for this activity
    TypedArray a = theme.obtainStyledAttributes(
            com.android.internal.R.styleable.ActivityTaskDescription);
    if (mTaskDescription.getPrimaryColor() == 0) {
        int colorPrimary = a.getColor(
                com.android.internal.R.styleable.ActivityTaskDescription_colorPrimary, 0);
        if (colorPrimary != 0 && Color.alpha(colorPrimary) == 0xFF) {
            mTaskDescription.setPrimaryColor(colorPrimary);
        }
    }
    // For dev-preview only.
    if (mTaskDescription.getBackgroundColor() == 0) {
        int colorBackground = a.getColor(
                com.android.internal.R.styleable.ActivityTaskDescription_colorBackground, 0);
        if (colorBackground != 0 && Color.alpha(colorBackground) == 0xFF) {
            mTaskDescription.setBackgroundColor(colorBackground);
        }
    }
    a.recycle();
    setTaskDescription(mTaskDescription);
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:36,代碼來源:a.java

示例3: init

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
@SuppressWarnings("ConstantConditions")
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	if (!isInEditMode()) {
		final Resources.Theme theme = context.getTheme();
		// Try to apply font presented within text appearance style.
		final TypedArray appearanceAttributes = theme.obtainStyledAttributes(attrs, new int[]{android.R.attr.textAppearance}, defStyleAttr, defStyleRes);
		final int appearance = appearanceAttributes.getResourceId(0, -1);
		if (appearance != -1) {
			FontApplier.DEFAULT.applyFont(this, appearance);
		}
		appearanceAttributes.recycle();
		// Try to apply font presented within xml attributes.
		FontApplier.DEFAULT.applyFont(this, attrs, defStyleAttr, defStyleRes);
	}
	// Default set up.
	this.mLocale = Locale.getDefault();
	this.handleLocaleChange();

	final TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.Ui_MonthView, defStyleAttr, defStyleRes);
	this.processTintValues(context, attributes);
	for (int i = 0; i < attributes.getIndexCount(); i++) {
		final int index = attributes.getIndex(i);
		if (index == R.styleable.Ui_MonthView_android_horizontalSpacing) {
			this.mSpacingHorizontal = attributes.getDimensionPixelSize(index, mSpacingHorizontal);
		} else if (index == R.styleable.Ui_MonthView_android_verticalSpacing) {
			this.mSpacingVertical = attributes.getDimensionPixelSize(index, mSpacingVertical);
		} else if (index == R.styleable.Ui_MonthView_uiMonthDayLettersOffsetVertical) {
			this.mDayLettersOffsetVertical = attributes.getDimensionPixelSize(index, mDayLettersOffsetVertical);
		} else if (index == R.styleable.Ui_MonthView_uiMonthDayNumbersOffsetVertical) {
			this.mDayNumbersOffsetVertical = attributes.getDimensionPixelOffset(index, mDayNumbersOffsetVertical);
		} else if (index == R.styleable.Ui_MonthView_uiMonthTitleTextAppearance) {
			setTitleTextAppearance(attributes.getResourceId(index, 0));
		} else if (index == R.styleable.Ui_MonthView_uiMonthDayLetterTextAppearance) {
			setDayLetterTextAppearance(attributes.getResourceId(index, 0));
		} else if (index == R.styleable.Ui_MonthView_uiMonthDayNumberTextAppearance) {
			setDayNumberTextAppearance(attributes.getResourceId(index, 0));
		} else if (index == R.styleable.Ui_MonthView_uiMonthDaySelector) {
			setDaySelector(attributes.getResourceId(index, 0));
		} else if (index == R.styleable.Ui_MonthView_uiMonthDaySelectorRadius) {
			setDaySelectorRadius(attributes.getDimensionPixelSize(index, mDaySelectorRadius));
		} else if (index == R.styleable.Ui_MonthView_uiMonthCurrentDayTextColor) {
			setCurrentDayTextColor(attributes.getColorStateList(index));
		}
	}
	attributes.recycle();
	this.applyDaySelectorTint();
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:56,代碼來源:MonthView.java

示例4: selectableItemBackground

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Applies to view default background drawable which contains focus and pressed states.
 *
 * @param view View whose background drawable should be changed.
 */
public static void selectableItemBackground(@NonNull final View view) {
    final Resources.Theme theme = view.getContext().getTheme();
    final TypedValue outValue = new TypedValue();
    if (theme.resolveAttribute(R.attr.selectableItemBackground, outValue, true)) {
        view.setBackgroundResource(outValue.resourceId);
    }
}
 
開發者ID:GlobusLTD,項目名稱:recyclerview-android,代碼行數:13,代碼來源:TouchFeedback.java

示例5: createFromXmlInner

import android.content.res.Resources; //導入方法依賴的package包/類
@SuppressLint("NewApi")
@Override
public Drawable createFromXmlInner(@NonNull Context context, @NonNull XmlPullParser parser,
                                   @NonNull AttributeSet attrs, @Nullable Resources.Theme theme) {
    try {
        return VectorDrawableCompat
                .createFromXmlInner(context.getResources(), parser, attrs, theme);
    } catch (Exception e) {
        Log.e("VdcInflateDelegate", "Exception while inflating <vector>", e);
        return null;
    }
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:13,代碼來源:SkinCompatDrawableManager.java

示例6: shouldBeFloatingWindow

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Returns true if the theme sets the {@code R.attr.isFloatingWindow} flag to true.
 */
protected boolean shouldBeFloatingWindow() {
    Resources.Theme theme = getTheme();
    TypedValue floatingWindowFlag = new TypedValue();

    // Check isFloatingWindow flag is defined in theme.
    if (theme == null || !theme
            .resolveAttribute(R.attr.isFloatingWindow, floatingWindowFlag, true)) {
        return false;
    }

    return (floatingWindowFlag.data != 0);
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:16,代碼來源:BaseActivity.java

示例7: theme

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * @see GlideOptions#theme(Resources.Theme)
 */
@CheckResult
public GlideRequest<TranscodeType> theme(@Nullable Resources.Theme arg0) {
  if (getMutableOptions() instanceof GlideOptions) {
    this.requestOptions = ((GlideOptions) getMutableOptions()).theme(arg0);
  } else {
    this.requestOptions = new GlideOptions().apply(this.requestOptions).theme(arg0);
  }
  return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:GlideRequest.java

示例8: applyNavigationIcon

import android.content.res.Resources; //導入方法依賴的package包/類
public static void applyNavigationIcon(ThemeUiInterface ci, Resources.Theme theme, int paramInt) {
    TypedArray ta = theme.obtainStyledAttributes(new int[]{paramInt});
    int id = ta.getResourceId(0, 0);
    if(null != ci) {
        try {
            ((Toolbar)ci.getView()).setNavigationIcon(id);
        } catch (ClassCastException e){
            e.printStackTrace();
        }
    }
    ta.recycle();
}
 
開發者ID:vitaviva,項目名稱:MultipleTheme,代碼行數:13,代碼來源:ViewAttributeUtil.java

示例9: makeChange

import android.content.res.Resources; //導入方法依賴的package包/類
private void makeChange(int themeId){
    Resources.Theme theme = mContext.getTheme();
    for(ViewSetter setter : mViewSetters){
        setter.setValue(theme, themeId);
    }

}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:8,代碼來源:MyThemeChanger.java

示例10: changeChildrenAttrs

import android.content.res.Resources; //導入方法依賴的package包/類
private void changeChildrenAttrs(ViewGroup targetViewGroup, Resources.Theme theme, int themeId){
    int count = targetViewGroup.getChildCount();
    //遍曆到每一個item
    for(int i = 0; i<count; i++){
        View childView = targetViewGroup.getChildAt(i);
        for(ViewSetter setter : mItemChildViewSetters){
            setter.mTargetView = ((ViewGroup)childView).findViewById(setter.mTargetViewId);
            if(setter.mTargetView != null){
                setter.setValue(theme, themeId);
            }
        }
    }
}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:14,代碼來源:ListAndRecyclerSetter.java

示例11: getVectorDrawable

import android.content.res.Resources; //導入方法依賴的package包/類
public static Drawable getVectorDrawable(@NonNull Resources res, @DrawableRes int resId, @Nullable Resources.Theme theme) {
    if (Build.VERSION.SDK_INT >= 21) {
        return res.getDrawable(resId, theme);
    }
    return VectorDrawableCompat.create(res, resId, theme);
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:7,代碼來源:Util.java

示例12: setTheme

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public void setTheme(Resources.Theme themeId) {
    if(attr_background != -1) {
        ViewAttributeUtil.applyBackgroundDrawable(this, themeId, attr_background);
    }
}
 
開發者ID:vitaviva,項目名稱:MultipleTheme,代碼行數:7,代碼來源:ThemedCheckedBox.java

示例13: getPlaceholderRes

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public @DrawableRes int getPlaceholderRes(Resources.Theme theme) {
    return ResUtil.getDrawableRes(theme, R.attr.conversation_icon_attach_file);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:5,代碼來源:FileSlide.java

示例14: getTheme

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public Resources.Theme getTheme() {
    return null;
}
 
開發者ID:scintill,項目名稱:android-runas,代碼行數:5,代碼來源:CliContext.java

示例15: theme

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
@CheckResult
public final GlideOptions theme(@Nullable Resources.Theme arg0) {
  return (GlideOptions) super.theme(arg0);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:GlideOptions.java


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