本文整理汇总了Java中android.support.v7.widget.AppCompatDrawableManager.get方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatDrawableManager.get方法的具体用法?Java AppCompatDrawableManager.get怎么用?Java AppCompatDrawableManager.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.AppCompatDrawableManager
的用法示例。
在下文中一共展示了AppCompatDrawableManager.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FloatingActionButton
import android.support.v7.widget.AppCompatDrawableManager; //导入方法依赖的package包/类
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mShadowPadding = new Rect();
ThemeUtils.checkAppCompatTheme(context);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.Widget_Design_FloatingActionButton);
this.mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint);
this.mBackgroundTintMode = parseTintMode(a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null);
this.mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
this.mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, 0);
this.mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0.0f);
float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0.0f);
this.mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
a.recycle();
this.mImageHelper = new AppCompatImageHelper(this, AppCompatDrawableManager.get());
this.mImageHelper.loadFromAttributes(attrs, defStyleAttr);
this.mImagePadding = (getSizeDimension() - ((int) getResources().getDimension(R.dimen.design_fab_image_size))) / 2;
getImpl().setBackgroundDrawable(this.mBackgroundTint, this.mBackgroundTintMode, this.mRippleColor, this.mBorderWidth);
getImpl().setElevation(elevation);
getImpl().setPressedTranslationZ(pressedTranslationZ);
getImpl().updatePadding();
}
示例2: init
import android.support.v7.widget.AppCompatDrawableManager; //导入方法依赖的package包/类
private void init(final AttributeSet attrs, final int defStyleAttr) {
final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
R.styleable.IcButtonStyle, defStyleAttr, 0);
try {
final AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
Drawable rightIcon = a.getDrawableIfKnown(R.styleable.IcButtonStyle_rightIcon);
int id = a.getResourceId(R.styleable.IcButtonStyle_rightIcon, -1);
if (id != -1) {
rightIcon = drawableManager.getDrawable(getContext(), id);
}
Drawable topIcon = a.getDrawableIfKnown(R.styleable.IcButtonStyle_topIcon);
id = a.getResourceId(R.styleable.IcButtonStyle_topIcon, -1);
if (id != -1) {
topIcon = drawableManager.getDrawable(getContext(), id);
}
setCompoundDrawablesWithIntrinsicBounds(null, topIcon, rightIcon, null);
} finally {
a.recycle();
}
}
示例3: setNavButtonDrawable
import android.support.v7.widget.AppCompatDrawableManager; //导入方法依赖的package包/类
public static void setNavButtonDrawable(Context context, ImageButton left, ImageButton right,
int monthTextAppearanceResId) {
// Retrieve the previous and next drawables
AppCompatDrawableManager dm = AppCompatDrawableManager.get();
Drawable prevDrawable = dm.getDrawable(context, R.drawable.ic_chevron_left_black_24dp);
Drawable nextDrawable = dm.getDrawable(context, R.drawable.ic_chevron_right_black_24dp);
// Proxy the month text color into the previous and next drawables.
final TypedArray ta = context.obtainStyledAttributes(null,
new int[]{android.R.attr.textColor}, 0, monthTextAppearanceResId);
final ColorStateList monthColor = ta.getColorStateList(0);
if (monthColor != null) {
DrawableCompat.setTint(DrawableCompat.wrap(prevDrawable), monthColor.getDefaultColor());
DrawableCompat.setTint(DrawableCompat.wrap(nextDrawable), monthColor.getDefaultColor());
}
ta.recycle();
// Set the previous and next drawables
left.setImageDrawable(prevDrawable);
right.setImageDrawable(nextDrawable);
}
示例4: LegendItemView
import android.support.v7.widget.AppCompatDrawableManager; //导入方法依赖的package包/类
public LegendItemView(@NonNull Context context, @NonNull LegendItem item) {
super(context);
this.mContext = context;
this.setText(item.text);
this.setClickable(false);
this.setFocusable(false);
this.setTextSize(item.textsize);
this.setCompoundDrawablePadding(6);
this.setSingleLine(true);
if (item.typeface!=null) this.setTypeface(item.typeface);
this.setGravity(Gravity.CENTER_VERTICAL);
this.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
// detect RTL environment
final boolean rtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
Drawable start, end;
// Account for RTL and
if (item.iconid==0) {
final Drawable marker = createMarker(item.color);
start = rtl ? null : marker;
end = rtl ? marker : null;
} else {
// Obtain DrawableManager
final AppCompatDrawableManager dm = AppCompatDrawableManager.get();
start = rtl ? null : dm.getDrawable(context, item.iconid);
end = rtl ? dm.getDrawable(context, item.iconid) : null;
Utils.PVGColors.tintMyDrawable(start, item.color);
}
// apply the compound Drawables
setCompoundDrawablesWithIntrinsicBounds(start, null, end, null);
}
示例5: setupCheckBox
import android.support.v7.widget.AppCompatDrawableManager; //导入方法依赖的package包/类
private static void setupCheckBox(CheckBox checkBox) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
checkBox.setButtonDrawable(R.drawable.btn_checkbox_circle);
checkBox.setBackgroundResource(R.drawable.btn_checkbox_circle_background);
} else {
Context context = checkBox.getContext();
AppCompatDrawableManager dm = AppCompatDrawableManager.get();
StateListDrawable button = new StateListDrawable();
button.addState(new int[]{android.R.attr.state_checked},
dm.getDrawable(context, R.drawable.ic_checkbox_circle_checked));
button.addState(new int[]{},
dm.getDrawable(context, R.drawable.ic_checkbox_circle_unchecked));
ColorStateList buttonTint = new ColorStateList(new int[][]{ // states
new int[]{android.R.attr.state_checked},
new int[]{} // state_default
}, new int[]{ // colors
ThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated),
ThemeUtils.getThemeAttrColor(context, R.attr.colorControlNormal)
});
Drawable buttonCompat = DrawableCompat.wrap(button);
DrawableCompat.setTintList(buttonCompat, buttonTint);
checkBox.setButtonDrawable(buttonCompat);
ShapeDrawable background = new ShapeDrawable(new OvalShape());
int backgroundTint = ThemeUtils.getThemeAttrColor(context, android.R.attr.colorBackground);
Drawable backgroundCompat = DrawableCompat.wrap(background);
DrawableCompat.setTint(backgroundCompat, backgroundTint);
ViewCompatUtils.setBackground(checkBox, backgroundCompat);
}
}
示例6: updateTintList
import android.support.v7.widget.AppCompatDrawableManager; //导入方法依赖的package包/类
protected void updateTintList() {
if (mUpdateTintList) {
mUpdateTintList = false;
Drawable rootDrawable = getRootDrawable(this);
View view = getView(rootDrawable);
Context context = getContext(view);
if (context != null) {
AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
// The context wrapper ensures that the manager doesn't reuse old tint lists.
Context contextWrapper = new ContextWrapper(context);
ColorStateList tintList = drawableManager.getTintList(contextWrapper, mState.mId);
if (tintList != null && isTintableBackground(view, rootDrawable)) {
ColorStateList viewTintList = ((TintableBackgroundView) view).getSupportBackgroundTintList();
// TintableBackgroundViews store internal tintLists for known drawables.
// Those tintLists can become outdated, if they contain attributes that are code-colors.
// We make sure to store and enforce different tintList every time the code-colors change.
if (viewTintList == null || viewTintList == mTintList) {
((TintableBackgroundView) view).setSupportBackgroundTintList(tintList);
}
mTintList = tintList;
} else {
// If tint list is null, tintDrawable will still try to set color filters.
CcTintManager.tintDrawable(context, tintList, mDrawable, mState.mId);
}
}
}
}
示例7: vector
import android.support.v7.widget.AppCompatDrawableManager; //导入方法依赖的package包/类
private void vector(CompositionAvatarView view) {
AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
view.addDrawable(drawableManager.getDrawable(this, R.drawable.cloud_circle));
view.addDrawable(drawableManager.getDrawable(this, R.drawable.album));
view.addDrawable(drawableManager.getDrawable(this, R.drawable.group_work));
}