本文整理汇总了Java中android.support.v4.graphics.drawable.DrawableCompat.setTint方法的典型用法代码示例。如果您正苦于以下问题:Java DrawableCompat.setTint方法的具体用法?Java DrawableCompat.setTint怎么用?Java DrawableCompat.setTint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.graphics.drawable.DrawableCompat
的用法示例。
在下文中一共展示了DrawableCompat.setTint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTag
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void createTag(String s, @ColorInt int tintColor) {
TextView textView = new TextView(getContext());
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.rightMargin = dp2px(4);
textView.setLayoutParams(lp);
textView.setTextSize(9);
Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.shape_round_stroke_bg_tag);
DrawableCompat.setTint(drawable, tintColor);
if (Build.VERSION.SDK_INT > 15)
textView.setBackground(drawable);
else
textView.setBackgroundDrawable(drawable);
textView.setPadding(dp2px(2), 0, dp2px(2), 0);
textView.setText(s);
addView(textView);
}
示例2: setStyle
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
void setStyle(TextSection section) {
switch (section.getAlignment()) {
case TextSection.LEFT:
DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xff24cf5f);
DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xFFFFFFFF);
DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xFFFFFFFF);
break;
case TextSection.CENTER:
DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xFFFFFFFF);
DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xff24cf5f);
DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xFFFFFFFF);
break;
case TextSection.RIGHT:
DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xFFFFFFFF);
DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xFFFFFFFF);
DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xff24cf5f);
break;
}
}
示例3: setUpCastButton
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void setUpCastButton() {
if (TextUtils.isEmpty(getString(R.string.cast_app_id)))
return;
if (castContext != null && castSession != null) {
Drawable remoteIndicatorDrawable = getRemoteIndicatorDrawable();
DrawableCompat.setTint(remoteIndicatorDrawable, ContextCompat.getColor(this, android.R.color.white));
mediaRouteButton.setRemoteIndicatorDrawable(remoteIndicatorDrawable);
CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), mediaRouteButton);
}
}
示例4: onCreate
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
AudioPickerConfig config = (AudioPickerConfig) FilePicker.getPickerConfig();
isNeedRecorder = config.isNeedRecord();
super.onCreate(savedInstanceState);
mContentView.setBackgroundColor(Color.WHITE);
mAdapter = new AudioPickerAdapter(this,new ArrayList<AudioFile>());
mRecyclerView.setAdapter(mAdapter);
Drawable drawable = getResources().getDrawable(R.mipmap.ic_record_audio);
Drawable wrap = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(wrap,Color.GRAY);
setEmptyImageView(wrap);
setEmptyTvTip(getString(R.string.click_to_record_audio));
setEmptyTextViewTextColor(Color.BLACK);
setEmptyImageViewAction(new View.OnClickListener() {
@Override
public void onClick(View v) {
Util.launchRecorder(new Util.RequestPermission() {
@Override
public void onRequestPermissionSuccess() {
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, REQUEST_CODE_TAKE_AUDIO);
}
}, AudioPickerActivity.this);
}
});
}
示例5: onCreateOptionsMenu
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.exif_editor, menu);
this.menu = menu;
MenuItem save = menu.findItem(R.id.save);
save.setVisible(editedItems.size() > 0);
Drawable d = save.getIcon();
DrawableCompat.wrap(d);
DrawableCompat.setTint(d, textColorSecondary);
DrawableCompat.unwrap(d);
save.setIcon(d);
return super.onCreateOptionsMenu(menu);
}
示例6: setDrawableColor
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public static void setDrawableColor(TextView view, int color){
Drawable[] drawables=view.getCompoundDrawables();
for(Drawable drawable:drawables){
if(drawable!=null){
drawable.mutate();
DrawableCompat.setTint(drawable,color);
}
}
}
示例7: setUpCastButton
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void setUpCastButton() {
if (TextUtils.isEmpty(getString(R.string.cast_app_id)))
return;
if (castContext != null && castSession != null) {
Drawable remoteIndicatorDrawable = getRemoteIndicatorDrawable();
DrawableCompat.setTint(remoteIndicatorDrawable, ContextCompat.getColor(getContext(), android.R.color.white));
mediaRouteButton.setRemoteIndicatorDrawable(remoteIndicatorDrawable);
CastButtonFactory.setUpMediaRouteButton(getContext().getApplicationContext(), mediaRouteButton);
}
}
示例8: initClearDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void initClearDrawable(Context context) {
mClearDrawable = getCompoundDrawables()[2];// 获取EditText的DrawableRight,假如没有设置我们就使用默认的图片
if (mClearDrawable == null) {
// mClearDrawable = getResources().getDrawable(R.drawable.search_cancel, context.getTheme());
mClearDrawable = getResources().getDrawable(R.drawable.search_cancel);
}
DrawableCompat.setTint(mClearDrawable, DrawableColor);// 设置删除按钮的颜色和TextColor的颜色一致
mClearDrawable.setBounds(0, 0, (int) getTextSize(), (int) getTextSize());// 设置Drawable的宽高和TextSize的大小一致
setClearIconVisible(false);
// 设置焦点改变的监听
setOnFocusChangeListener(this);
// 设置输入框里面内容发生改变的监听
addTextChangedListener(this);
}
示例9: init
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
@Override
protected void init() {
super.init();
if (mPath == null) {
mPath = getArguments().getString(PATH_INTENT);
}
if (mExtension == null) {
mExtension = getArguments().getString(EXTENSION_INTENT);
}
int accentColor = ViewUtils.getThemeAccentColor(getContext());
if (mDirImage == null) {
mDirImage = DrawableCompat.wrap(ContextCompat.getDrawable(getActivity(), R.drawable.ic_dir));
DrawableCompat.setTint(mDirImage, accentColor);
}
if (mFileImage == null) {
mFileImage = DrawableCompat.wrap(ContextCompat.getDrawable(getActivity(), R.drawable.ic_file));
DrawableCompat.setTint(mFileImage, ViewUtils.getTextSecondaryColor(getContext()));
}
if (mPickDialog != null) {
mPickDialog.show();
}
ActionBar actionBar;
if ((actionBar = ((FilePickerActivity) getActivity()).getSupportActionBar()) != null) {
actionBar.setTitle(mPath);
}
}
示例10: createTintedDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
@CheckResult
@Nullable
public static Drawable createTintedDrawable(@Nullable Drawable drawable, @ColorInt int color) {
if (drawable == null) return null;
drawable = DrawableCompat.wrap(drawable.mutate());
DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
DrawableCompat.setTint(drawable, color);
return drawable;
}
示例11: bind
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public void bind(ServerListAdapter adapter, ServerConfigData data) {
mConfigData = data;
Drawable d = DrawableCompat.wrap(mIconBg.getBackground());
DrawableCompat.setTint(d, adapter.mColorInactive);
mIconBg.setBackgroundDrawable(d);
mName.setText(data.name);
}
示例12: setTintedVectorDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void setTintedVectorDrawable(ImageView imageView, int color) {
//option1. create vector drawable and tint it(this method resize the image
// VectorDrawableCompat drawable=VectorDrawableCompat.create(mContext.getResources(),drawableResId,null);
// if(drawable==null) return;
// drawable.setTint(color);
// convert tinted vector drawable to bitmap
// Bitmap bitmap= Utils.createScaledBitMapFromVectorDrawable(mContext,drawable,40f);
// imageView.setImageBitmap(bitmap);
// option2: much better, reduce stuttering when scrolling
DrawableCompat.setTint(imageView.getDrawable(), color);
}
示例13: init
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AnimatedPencil);
if (typedArray != null) {
color = typedArray.getColor(R.styleable.AnimatedPencil_pencil_color, color);
typedArray.recycle();
}
imageView = new AppCompatImageView(getContext());
addView(imageView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
drawable = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.awsb_ic_edit_animated_24);
drawable = DrawableCompat.wrap(drawable).mutate();
DrawableCompat.setTint(drawable, color);
imageView.setImageDrawable(drawable);
}
示例14: init
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void init(final Context context) {
final Drawable drawable = ContextCompat.getDrawable(context, R.mipmap.ic_delete);
final Drawable wrappedDrawable = DrawableCompat.wrap(drawable); //Wrap the drawable so that it can be tinted pre Lollipop
DrawableCompat.setTint(wrappedDrawable, getCurrentHintTextColor());
mClearTextIcon = wrappedDrawable;
mClearTextIcon.setBounds(0, 0, mClearTextIcon.getIntrinsicHeight(), mClearTextIcon.getIntrinsicHeight());
setClearIconVisible(false);
super.setOnTouchListener(this);
super.setOnFocusChangeListener(this);
addTextChangedListener(this);
}
示例15: tint
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
static public void tint(@NonNull final Drawable drawable, int iconTint)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
drawable.setTint(iconTint);
}
else
{
DrawableCompat.setTint(DrawableCompat.wrap(drawable), iconTint);
}
}