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


Java PorterDuff类代码示例

本文整理汇总了Java中android.graphics.PorterDuff的典型用法代码示例。如果您正苦于以下问题:Java PorterDuff类的具体用法?Java PorterDuff怎么用?Java PorterDuff使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PorterDuff类属于android.graphics包,在下文中一共展示了PorterDuff类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Holder

import android.graphics.PorterDuff; //导入依赖的package包/类
Holder(View itemView) {
    super(itemView);
    this.tag = (TextView) itemView.findViewById(R.id.log_tag);
    this.datetime = (TextView) itemView.findViewById(R.id.log_datetime);
    this.body = (TextView) itemView.findViewById(R.id.log_body);

    this.buttonShare = itemView.findViewById(R.id.log_button_share);

    this.bodyRoot = itemView.findViewById(R.id.log_body_root);
    this.buttonExpand = itemView.findViewById(R.id.log_button_expand);

    Context context = itemView.getContext();

    ImageView icon = (ImageView) itemView.findViewById(R.id.log_icon);
    icon.getBackground().setColorFilter(CurrentTheme.getColorPrimary(context), PorterDuff.Mode.MULTIPLY);
    icon.setColorFilter(CurrentTheme.getIconColorOnColoredBackgroundCode(context));
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:18,代码来源:LogsAdapter.java

示例2: onCreate

import android.graphics.PorterDuff; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);

    getSupportActionBar().setTitle(getString(R.string.about));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    progressBar = (ProgressBar) findViewById(R.id.progress);
    progressBar.getIndeterminateDrawable()
            .setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
    info_web = (WebView) findViewById(R.id.webview_company_info);
    info_web.setBackgroundColor(Color.TRANSPARENT);
    info_web.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    info_web.setWebViewClient(new myWebClient());
    info_web.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    info_web.getSettings().setJavaScriptEnabled(true);
    String infoText = getString(R.string.company_info_web);
    info_web.loadDataWithBaseURL("file:///android_asset/fonts/", getWebViewText(infoText), "text/html", "utf-8", null);

}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:22,代码来源:AboutActivity.java

示例3: highlight

import android.graphics.PorterDuff; //导入依赖的package包/类
public View highlight(String projectName, boolean b) {
    View v = mGrid.findViewWithTag(projectName);
    v.setSelected(b);
    //TODO reenable this
    //mProjectAdapter.mData.get(mProjectAdapter.findAppIdByName(projectName)).selected = true;
    v.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY);

    return v;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:10,代码来源:ProjectListFragment.java

示例4: getCroppedBitmap

import android.graphics.PorterDuff; //导入依赖的package包/类
public static Bitmap getCroppedBitmap(Bitmap bitmap) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    // canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
            bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    //Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false);
    //return _bmp;
    return output;
}
 
开发者ID:thenewpotato,项目名称:Blogg,代码行数:22,代码来源:Tools.java

示例5: onDraw

import android.graphics.PorterDuff; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    Theme.backgroundMediaDrawableIn.setColorFilter(themePrefs.getInt("chatLBubbleColor", 0xfffafafa), PorterDuff.Mode.SRC_IN);
    int x = (canvas.getWidth() - width) / 2;
    int y = AndroidUtilities.dp(4);
    Theme.backgroundMediaDrawableIn.setBounds(x, y, width + x, height + y);
    Theme.backgroundMediaDrawableIn.draw(canvas);
    canvas.save();
    canvas.translate(textX = AndroidUtilities.dp(2 + 9) + x, textY = AndroidUtilities.dp(2 + 9) + y);
    if (pressedLink != null) {
        canvas.drawPath(urlPath, urlPaint);
    }
    if (textLayout != null) {
        textLayout.draw(canvas);
    }
    canvas.restore();
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:19,代码来源:BotHelpCell.java

示例6: CircleColorImageView

import android.graphics.PorterDuff; //导入依赖的package包/类
public CircleColorImageView(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  int circleColor = Color.WHITE;

  if (attrs != null) {
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CircleColorImageView, 0, 0);
    circleColor = typedArray.getColor(R.styleable.CircleColorImageView_circleColor, Color.WHITE);
    typedArray.recycle();
  }

  Drawable circle = context.getResources().getDrawable(R.drawable.circle_tintable);
  circle.setColorFilter(circleColor, PorterDuff.Mode.SRC_IN);

  setBackgroundDrawable(circle);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:17,代码来源:CircleColorImageView.java

示例7: updateTheme

import android.graphics.PorterDuff; //导入依赖的package包/类
private void updateTheme(){
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
    try{

        Drawable floatingDrawableWhite = getParentActivity().getResources().getDrawable(R.drawable.floating_white);
        if(floatingDrawableWhite != null)floatingDrawableWhite.setColorFilter(themePrefs.getInt("chatsFloatingBGColor", def), PorterDuff.Mode.MULTIPLY);
        floatingButton.setBackgroundDrawable(floatingDrawableWhite);
        Drawable pencilDrawableWhite = getParentActivity().getResources().getDrawable(R.drawable.ic_float_sms);
        if(pencilDrawableWhite != null)pencilDrawableWhite.setColorFilter(themePrefs.getInt("chatsFloatingPencilColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
        floatingButton.setImageDrawable(pencilDrawableWhite);
    } catch (NullPointerException e) {
        FileLog.e("tmessages", e);
    }

}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:17,代码来源:ProfileActivity.java

示例8: initView

import android.graphics.PorterDuff; //导入依赖的package包/类
private void initView(Context context) {
        normalDrawable = ContextCompat.getDrawable(getContext(), R.drawable.base_icon_download);
        finishDrawable = ContextCompat.getDrawable(getContext(), R.drawable.base_icon_yixiazai);
        if (isInEditMode()) {
            SkinHelper.init(context);
        } else {
            finishDrawable.mutate().setColorFilter(SkinHelper.getSkin().getThemeSubColor(), PorterDuff.Mode.MULTIPLY);
        }

        normalDrawable.setBounds(0, 0, normalDrawable.getIntrinsicWidth(), normalDrawable.getIntrinsicHeight());
        finishDrawable.setBounds(0, 0, normalDrawable.getIntrinsicWidth(), normalDrawable.getIntrinsicHeight());

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mStrokeWidth = 2 * getResources().getDisplayMetrics().density;
        mPaint.setStrokeWidth(mStrokeWidth);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeCap(Paint.Cap.ROUND);//设置笔触的模式
//        mPaint.setStrokeJoin(Paint.Join.ROUND);//设置连接模式, 在绘制矩形各个角的时候有效果

        oval = new RectF();
    }
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:22,代码来源:RDownloadView.java

示例9: onViewCreated

import android.graphics.PorterDuff; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    toolbar.getNavigationIcon().setColorFilter(
            getResources().getColor(R.color.icon_grey), PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationOnClickListener(v -> getActivity().onBackPressed());

    int padding = getResources().getDimensionPixelSize(R.dimen.about_header_padding);
    bannerImage.setPadding(padding, padding, padding, padding);
    Glide.with(this)
            .load(R.drawable.egg)
            .into(bannerImage);

    Spannable span = new SpannableString(title.getContext().getString(R.string.about_title));
    span.setSpan(new TextAppearanceSpan(title.getContext(),
                    R.style.ProteinTextAppearance_Regular_XXL_Primary), 0, 7,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    span.setSpan(new TextAppearanceSpan(title.getContext(),
                    R.style.ProteinTextAppearance_Regular_L_Hint), 7, span.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    title.setText(span);
    versionName.setText(versionName.getContext().getString(R.string.about_version, BuildConfig.VERSION_NAME));

    layoutGe.setOnClickListener(aboutOnClickListener);
    layoutMelodie.setOnClickListener(aboutOnClickListener);
    layoutOthers.setOnClickListener(aboutOnClickListener);
    versionLayout.setOnClickListener(aboutOnClickListener);
    licenseLayout.setOnClickListener(aboutOnClickListener);
    shareLayout.setOnClickListener(aboutOnClickListener);
}
 
开发者ID:gejiaheng,项目名称:Protein,代码行数:33,代码来源:AboutFragment.java

示例10: drawDrawable

import android.graphics.PorterDuff; //导入依赖的package包/类
/**
 * draw Rounded Rectangle
 *
 * @param canvas
 * @param bitmap
 */
private void drawDrawable(Canvas canvas, Bitmap bitmap) {
    Paint paint = new Paint();
    paint.setColor(0xffffffff);
    paint.setAntiAlias(true); //smooths out the edges of what is being drawn
    PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
    // set flags
    int saveFlags = Canvas.MATRIX_SAVE_FLAG
            | Canvas.CLIP_SAVE_FLAG
            | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
            | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
            | Canvas.CLIP_TO_LAYER_SAVE_FLAG;
    canvas.saveLayer(0, 0, width, height, null, saveFlags);

    if (shapeType == 1) {
        canvas.drawCircle(width / 2, height / 2, width / 2 - 1, paint);
    } else if (shapeType == 2) {
        RectF rectf = new RectF(1, 1, getWidth() - 1, getHeight() - 1);
        canvas.drawRoundRect(rectf, radius + 1, radius + 1, paint);
    }

    paint.setXfermode(xfermode);

    float scaleWidth = ((float) getWidth()) / bitmap.getWidth();
    float scaleHeight = ((float) getHeight()) / bitmap.getHeight();

    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);

    //bitmap scale
    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);

    canvas.drawBitmap(bitmap, 0, 0, paint);
    canvas.restore();
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:41,代码来源:EaseImageView.java

示例11: GestureTrailsDrawingPreview

import android.graphics.PorterDuff; //导入依赖的package包/类
public GestureTrailsDrawingPreview(final TypedArray mainKeyboardViewAttr) {
    mDrawingParams = new GestureTrailDrawingParams(mainKeyboardViewAttr);
    final Paint gesturePaint = new Paint();
    gesturePaint.setAntiAlias(true);
    gesturePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
    mGesturePaint = gesturePaint;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:8,代码来源:GestureTrailsDrawingPreview.java

示例12: gradientBitmap

import android.graphics.PorterDuff; //导入依赖的package包/类
public static Bitmap gradientBitmap(Bitmap src, int color1, int color2) {
    int width = src.getWidth();
    int height = src.getHeight();
    Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(result);

    canvas.drawBitmap(src, 0, 0, null);

    Paint paint = new Paint();
    LinearGradient shader = new LinearGradient(0, 0, 0, height, color1, color2, Shader.TileMode.CLAMP);
    paint.setShader(shader);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawRect(0, 0, width, height, paint);

    return result;
}
 
开发者ID:TheAndroidMaster,项目名称:Asteroid,代码行数:17,代码来源:ImageUtils.java

示例13: GetCircleBitmap

import android.graphics.PorterDuff; //导入依赖的package包/类
public static Bitmap GetCircleBitmap(@NonNull Bitmap bitmap) {
    final Bitmap output = Bitmap.createBitmap(bitmap.getHeight(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(output);

    final int color = Color.BLACK;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getHeight(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawOval(rectF, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    bitmap.recycle();

    return output;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:22,代码来源:Tools.java

示例14: updateShuffleState

import android.graphics.PorterDuff; //导入依赖的package包/类
@Override
protected void updateShuffleState() {
    switch (MusicPlayerRemote.getShuffleMode()) {
        case MusicService.SHUFFLE_MODE_SHUFFLE:
            shuffleButton.setColorFilter(mLastPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
            break;
        default:
            shuffleButton.setColorFilter(mLastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN);
            break;
    }
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:12,代码来源:HmmPlaybackControlsFragment.java

示例15: initializeResources

import android.graphics.PorterDuff; //导入依赖的package包/类
private void initializeResources() {
  this.masterSecret   = getIntent().getParcelableExtra("master_secret");
  this.countrySpinner        = (Spinner) findViewById(R.id.country_spinner);
  this.countryCode           = (TextView) findViewById(R.id.country_code);
  this.number                = (TextView) findViewById(R.id.number);
  this.createButton          = (TextView) findViewById(R.id.registerButton);
  this.skipButton            = (TextView) findViewById(R.id.skipButton);
  this.informationView       = (TextView) findViewById(R.id.registration_information);
  this.informationToggle     =            findViewById(R.id.information_link_container);
  this.informationToggleText = (TextView) findViewById(R.id.information_label);

  this.createButton.getBackground().setColorFilter(ContextCompat.getColor(this, R.color.signal_primary),
                                                   PorterDuff.Mode.MULTIPLY);
  this.skipButton.getBackground().setColorFilter(ContextCompat.getColor(this, R.color.grey_400),
                                                 PorterDuff.Mode.MULTIPLY);

  this.countryCode.addTextChangedListener(new CountryCodeChangedListener());
  this.number.addTextChangedListener(new NumberChangedListener());
  this.createButton.setOnClickListener(new CreateButtonListener());
  this.skipButton.setOnClickListener(new CancelButtonListener());
  this.informationToggle.setOnClickListener(new InformationToggleListener());

  if (getIntent().getBooleanExtra("cancel_button", false)) {
    this.skipButton.setVisibility(View.VISIBLE);
  } else {
    this.skipButton.setVisibility(View.INVISIBLE);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:29,代码来源:RegistrationActivity.java


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