android.graphics.drawable.ColorDrawable#setAlpha()源码实例Demo

下面列出了android.graphics.drawable.ColorDrawable#setAlpha() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Camera2   文件: BottomBar.java
private void setPaintColor(int alpha, int color)
{
    if (mAnimatedCircleDrawable != null)
    {
        mAnimatedCircleDrawable.setColor(color);
        mAnimatedCircleDrawable.setAlpha(alpha);
    } else if (mColorDrawable != null)
    {
        mColorDrawable.setColor(color);
        mColorDrawable.setAlpha(alpha);
    }

    if (mIntentReviewLayout != null)
    {
        ColorDrawable intentBackground = (ColorDrawable) mIntentReviewLayout
                .getBackground();
        intentBackground.setColor(color);
        intentBackground.setAlpha(alpha);
    }
}
 
源代码2 项目: Camera2   文件: BottomBar.java
private void setCancelBackgroundColor(int alpha, int color)
{
    LayerDrawable layerDrawable = (LayerDrawable) mCancelButton.getBackground();
    Drawable d = layerDrawable.getDrawable(0);
    if (d instanceof AnimatedCircleDrawable)
    {
        AnimatedCircleDrawable animatedCircleDrawable = (AnimatedCircleDrawable) d;
        animatedCircleDrawable.setColor(color);
        animatedCircleDrawable.setAlpha(alpha);
    } else if (d instanceof ColorDrawable)
    {
        ColorDrawable colorDrawable = (ColorDrawable) d;
        if (!ApiHelper.isLOrHigher())
        {
            colorDrawable.setColor(color);
        }
        colorDrawable.setAlpha(alpha);
    }
}
 
源代码3 项目: Musicoco   文件: HomeBackgroundController.java
private void setImageBitmap(Bitmap bitmap) {
    if (bitmap != null) {

        // menu 中有图标时要通过 getHeaderView 查找子 view
        View headerView = navigationView.getHeaderView(0);
        ImageView iv = (ImageView) headerView.findViewById(R.id.main_left_nav_image);
        iv.setImageBitmap(bitmap);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            ColorDrawable cd = new ColorDrawable(Color.BLACK);
            int alpha = appPreference.getImageWallAlpha();
            cd.setAlpha(alpha);
            iv.setForeground(cd);
        }

        Animation animation = AnimationUtils.loadAnimation(activity, android.R.anim.fade_in);
        iv.startAnimation(animation);
    }

}
 
protected void loadChatConfig() {
    rightBubbleColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getRightBubbleColor());
    rightBubbleTextColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getRightBubbleTextColor());
    rightBubbleTimeColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getRightBubbleTimeColor());
    rightLinkTextColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getRightLinkTextColor());
    rightBubbleDrawable = ContextCompat.getDrawable(Qiscus.getApps(), R.drawable.qiscus_rounded_primary_light_chat_bg);
    rightBubbleDrawable.setColorFilter(rightBubbleColor, PorterDuff.Mode.SRC_ATOP);

    leftBubbleColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getLeftBubbleColor());
    leftBubbleTextColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getLeftBubbleTextColor());
    leftBubbleTimeColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getLeftBubbleTimeColor());
    leftLinkTextColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getLeftLinkTextColor());
    leftBubbleDrawable = ContextCompat.getDrawable(Qiscus.getApps(), R.drawable.qiscus_rounded_primary_chat_bg);
    leftBubbleDrawable.setColorFilter(leftBubbleColor, PorterDuff.Mode.SRC_ATOP);

    failedToSendMessageColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getFailedToSendMessageColor());
    readIconColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getReadIconColor());
    dateColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getDateColor());
    senderNameColor = ContextCompat.getColor(Qiscus.getApps(), Qiscus.getChatConfig().getSenderNameColor());
    selectionBackground = new ColorDrawable(ContextCompat.getColor(Qiscus.getApps(),
            Qiscus.getChatConfig().getSelectedBubbleBackgroundColor()));
    selectionBackground.setAlpha(51);
}
 
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mSearchView = (FloatingSearchView) view.findViewById(R.id.floating_search_view);
    mHeaderView = view.findViewById(R.id.header_view);

    mDimSearchViewBackground = view.findViewById(R.id.dim_background);
    mDimDrawable = new ColorDrawable(Color.BLACK);
    mDimDrawable.setAlpha(0);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mDimSearchViewBackground.setBackground(mDimDrawable);
    } else {
        mDimSearchViewBackground.setBackgroundDrawable(mDimDrawable);
    }

    setupFloatingSearch();
    setupDrawer();
}
 
源代码6 项目: TelePlus-Android   文件: InstantCameraView.java
@Keep
@Override
public void setAlpha(float alpha) {
    ColorDrawable colorDrawable = (ColorDrawable) getBackground();
    colorDrawable.setAlpha((int) (0xc0 * alpha));
    invalidate();
}
 
源代码7 项目: TelePlus-Android   文件: InstantCameraView.java
@Keep
@Override
public void setAlpha(float alpha) {
    ColorDrawable colorDrawable = (ColorDrawable) getBackground();
    colorDrawable.setAlpha((int) (0xc0 * alpha));
    invalidate();
}
 
源代码8 项目: Musicoco   文件: BottomNavigationController.java
@Override
public void themeChange(ThemeEnum themeEnum, int[] colors) {

    int[] cs = ColorUtils.get10ThemeColors(activity, themeEnum);

    int statusC = cs[0];
    int toolbarC = cs[1];
    int accentC = cs[2];
    int mainBC = cs[3];
    int vicBC = cs[4];
    int mainTC = cs[5];
    int vicTC = cs[6];
    int navC = cs[7];
    int toolbarMainTC = cs[8];
    int toolbarVicTC = cs[9];

    listViewsController.themeChange(themeEnum, cs);

    mContainer.setBackgroundColor(navC);
    mName.setTextColor(mainTC);
    mArts.setTextColor(vicTC);

    mPlay.setPauseLineColor(mainTC);
    mPlay.setSolidColor(mainTC);
    mPlay.setTriangleColor(mainTC);

    mProgress.setBackgroundColor(accentC);

    ColorDrawable cd = new ColorDrawable(vicBC);
    cd.setAlpha(200);
    mProgressBG.setBackground(cd);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mShowList.getDrawable().setTint(mainTC);
    }
}
 
源代码9 项目: Musicoco   文件: DialogUtils.java
public static void showDetailDialog(Activity activity, SongInfo info) {
    DialogProvider manager = new DialogProvider(activity);

    String[] infos = new String[7];
    infos[0] = "歌曲:" + info.getTitle();
    infos[1] = "歌手:" + info.getArtist();
    infos[2] = "专辑:" + info.getAlbum();
    infos[3] = "时长:" + StringUtils.getGenTimeMS((int) info.getDuration());
    infos[4] = "格式:" + info.getMime_type();
    infos[5] = "大小:" + String.valueOf(info.getSize() >> 10 >> 10) + " MB";
    infos[6] = "路径:" + info.getData();

    View view = activity.getLayoutInflater().inflate(R.layout.list_image, null);
    ListView listView = (ListView) view.findViewById(R.id.list_image_list);
    ImageView imageView = (ImageView) view.findViewById(R.id.list_image_image);
    listView.setAdapter(new ArrayAdapter<String>(
            activity,
            R.layout.text_view_start,
            infos
    ));

    Bitmap b = BitmapUtils.bitmapResizeFromFile(
            info.getAlbum_path(),
            imageView.getWidth(),
            imageView.getHeight());
    if (b == null) {
        b = BitmapUtils.getDefaultPictureForAlbum(activity, imageView.getWidth(), imageView.getHeight());
    }

    if (b != null) {
        imageView.setImageBitmap(b);
    }

    ColorDrawable drawable = new ColorDrawable(Color.WHITE);
    drawable.setAlpha(245);
    listView.setBackground(drawable);

    manager.createFullyCustomDialog(view, "歌曲信息").show();
}
 
源代码10 项目: Moring-Alarm   文件: BirdActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	int pos = 0;
	if (getIntent().getExtras() != null) {
		pos = getIntent().getExtras().getInt("pos");
	}
	
	String[] birds = getResources().getStringArray(R.array.birds);
	TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img);
	int resId = imgs.getResourceId(pos, -1);
	
	setTitle(birds[pos]);
	getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
	ColorDrawable color = new ColorDrawable(Color.BLACK);
	color.setAlpha(128);
	getSupportActionBar().setBackgroundDrawable(color);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	mHandler = new Handler();
	
	ImageView imageView = new ImageView(this);
	imageView.setScaleType(ScaleType.CENTER_INSIDE);
	imageView.setImageResource(resId);
	imageView.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
			getSupportActionBar().show();
			hideActionBarDelayed(mHandler);
		}
	});
	setContentView(imageView);
	this.getWindow().setBackgroundDrawableResource(android.R.color.black);
}
 
源代码11 项目: Moring-Alarm   文件: BirdActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	int pos = 0;
	if (getIntent().getExtras() != null) {
		pos = getIntent().getExtras().getInt("pos");
	}

	String[] birds = getResources().getStringArray(R.array.birds);
	TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img);
	int resId = imgs.getResourceId(pos, -1);

	setTitle(birds[pos]);
	getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
	ColorDrawable color = new ColorDrawable(Color.BLACK);
	color.setAlpha(128);
	getActionBar().setBackgroundDrawable(color);
	getActionBar().setDisplayHomeAsUpEnabled(true);
	mHandler = new Handler();

	ImageView imageView = new ImageView(this);
	imageView.setScaleType(ScaleType.CENTER_INSIDE);
	imageView.setImageResource(resId);
	imageView.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
			getActionBar().show();
			hideActionBarDelayed(mHandler);
		}
	});
	setContentView(imageView);
	this.getWindow().setBackgroundDrawableResource(android.R.color.black);
}
 
源代码12 项目: Musicoco   文件: BottomNavigationController.java
public void updateColors(int color, boolean isVarying) {

        ColorDrawable bd = new ColorDrawable(color);
        bd.setAlpha(100);
        mListTitleContainer.setBackground(bd);

        int colorA = ColorUtils.setAlphaComponent(color, 235);
        mViewRoot.setCardBackgroundColor(colorA);

        ThemeEnum t;
        if (com.duan.musicoco.util.ColorUtils.isBrightSeriesColor(colorA)) {
            t = WHITE;
        } else {
            t = DARK;
        }

        int cs[];
        switch (t) {
            case WHITE: {
                if (isVarying) {
                    cs = com.duan.musicoco.util.ColorUtils.get2ColorWhiteThemeForPlayOptions(activity);
                } else {
                    cs = com.duan.musicoco.util.ColorUtils.get2WhiteThemeTextColor(activity);
                }
                break;
            }
            case DARK:
            default: {
                if (isVarying) {
                    cs = com.duan.musicoco.util.ColorUtils.get2ColorDarkThemeForPlayOptions(activity);
                } else {
                    cs = com.duan.musicoco.util.ColorUtils.get2DarkThemeTextColor(activity);
                }
                break;
            }
        }
        songOption.setDrawableColor(cs[0]);
        listOption.setDrawableColor(cs[0]);

        if (playListAdapter != null) {
            playListAdapter.setMainTextColor(cs[0]);
            playListAdapter.setVicTextColor(cs[1]);
        }

        listOption.updateColors();
        songOption.updateColors();

    }
 
源代码13 项目: tickmate   文件: TickColor.java
public Drawable getDrawable(int alpha) {
    Log.d(TAG, "getTickedButtonDrawable " + getName());
    ColorDrawable cd = new ColorDrawable(Color.parseColor(hex()));
    cd.setAlpha(alpha);
    return cd;
}
 
源代码14 项目: Telegram-FOSS   文件: AnimationProperties.java
@Override
public void setValue(ColorDrawable object, int value) {
    object.setAlpha(value);
}
 
源代码15 项目: ifican   文件: TransitionActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transition);
    ButterKnife.inject(this);

    Bundle bundle = getIntent().getExtras();
    info = bundle.getParcelable("INFO");
    dog = bundle.getParcelable("DOG");

    background = new ColorDrawable(getResources().getColor(R.color.yellow));
    background.setAlpha(0);
    topLevel.setBackground(background);
    image.setImageResource(dog.getResource());

    text1.setText(Html.fromHtml(IOUtils.readFile(this, "source/itemclick.java.html")));
    text2.setText(Html.fromHtml(IOUtils.readFile(this, "source/predraw.java.html")));
    text3.setText(Html.fromHtml(IOUtils.readFile(this, "source/init.java.html")));
    text4.setText(Html.fromHtml(IOUtils.readFile(this, "source/anim1.java.html")));

    if (savedInstanceState == null){
        image.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                image.getViewTreeObserver().removeOnPreDrawListener(this);

                int[] screenLocation = new int[2];
                image.getLocationOnScreen(screenLocation);
                leftDelta = info.left - screenLocation[0];
                topDelta = info.top - screenLocation[1];

                // Scale factors to make the large version the same size as the thumbnail
                widthScale = (float) info.width / image.getWidth();
                heightScale = (float) info.height / image.getHeight();

                runEnterAnimation();

                return true;
            }
        });
    }
}
 
源代码16 项目: Telegram   文件: AnimationProperties.java
@Override
public void setValue(ColorDrawable object, int value) {
    object.setAlpha(value);
}