當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。