当前位置: 首页>>代码示例>>Java>>正文


Java DrawableCompat.setTint方法代码示例

本文整理汇总了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);
}
 
开发者ID:woxingxiao,项目名称:GracefulMovies,代码行数:18,代码来源:TagGroup.java

示例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;
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:20,代码来源:AlignPopupWindow.java

示例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);
    }
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:11,代码来源:VideoPlayerActivity.java

示例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);
        }
    });
}
 
开发者ID:liuke2016,项目名称:filepicker,代码行数:28,代码来源:AudioPickerActivity.java

示例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);
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:15,代码来源:ExifEditorActivity.java

示例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);
        }
    }
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:10,代码来源:PresentationUtils.java

示例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);
    }
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:11,代码来源:OfflineVideoDetailsFragment.java

示例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);

	}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:16,代码来源:OneKeyClearEditText.java

示例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);
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:28,代码来源:FilePickerActivity.java

示例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;
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:10,代码来源:TintHelper.java

示例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);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:8,代码来源:ServerListAdapter.java

示例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);


}
 
开发者ID:cahergil,项目名称:Farmacias,代码行数:16,代码来源:ListTabAdapter.java

示例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);
}
 
开发者ID:florent37,项目名称:AnimatedPencil,代码行数:14,代码来源:AnimatedPencil.java

示例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);
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:12,代码来源:AppCompatAutoCompleteClearTextView.java

示例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);
	}
}
 
开发者ID:1313ou,项目名称:TreebolicLib,代码行数:12,代码来源:Utils.java


注:本文中的android.support.v4.graphics.drawable.DrawableCompat.setTint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。