本文整理匯總了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);
}
}