本文整理匯總了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();
}
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例14: getTheme
import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public Resources.Theme getTheme() {
return null;
}
示例15: theme
import android.content.res.Resources; //導入方法依賴的package包/類
@Override
@CheckResult
public final GlideOptions theme(@Nullable Resources.Theme arg0) {
return (GlideOptions) super.theme(arg0);
}