Java Code Examples for android.graphics.drawable.ColorDrawable#setAlpha()
The following examples show how to use
android.graphics.drawable.ColorDrawable#setAlpha() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BottomBar.java From Camera2 with Apache License 2.0 | 6 votes |
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); } }
Example 2
Source File: BottomBar.java From Camera2 with Apache License 2.0 | 6 votes |
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); } }
Example 3
Source File: HomeBackgroundController.java From Musicoco with Apache License 2.0 | 6 votes |
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); } }
Example 4
Source File: QiscusBaseMessageViewHolder.java From qiscus-sdk-android with Apache License 2.0 | 6 votes |
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); }
Example 5
Source File: SlidingSearchViewExampleFragment.java From floatingsearchview with Apache License 2.0 | 6 votes |
@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(); }
Example 6
Source File: InstantCameraView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Keep @Override public void setAlpha(float alpha) { ColorDrawable colorDrawable = (ColorDrawable) getBackground(); colorDrawable.setAlpha((int) (0xc0 * alpha)); invalidate(); }
Example 7
Source File: InstantCameraView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Keep @Override public void setAlpha(float alpha) { ColorDrawable colorDrawable = (ColorDrawable) getBackground(); colorDrawable.setAlpha((int) (0xc0 * alpha)); invalidate(); }
Example 8
Source File: BottomNavigationController.java From Musicoco with Apache License 2.0 | 5 votes |
@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); } }
Example 9
Source File: DialogUtils.java From Musicoco with Apache License 2.0 | 5 votes |
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(); }
Example 10
Source File: BirdActivity.java From Moring-Alarm with Apache License 2.0 | 5 votes |
@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); }
Example 11
Source File: BirdActivity.java From Moring-Alarm with Apache License 2.0 | 5 votes |
@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); }
Example 12
Source File: BottomNavigationController.java From Musicoco with Apache License 2.0 | 4 votes |
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(); }
Example 13
Source File: TickColor.java From tickmate with GNU General Public License v3.0 | 4 votes |
public Drawable getDrawable(int alpha) { Log.d(TAG, "getTickedButtonDrawable " + getName()); ColorDrawable cd = new ColorDrawable(Color.parseColor(hex())); cd.setAlpha(alpha); return cd; }
Example 14
Source File: AnimationProperties.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void setValue(ColorDrawable object, int value) { object.setAlpha(value); }
Example 15
Source File: TransitionActivity.java From ifican with Apache License 2.0 | 4 votes |
@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; } }); } }
Example 16
Source File: AnimationProperties.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void setValue(ColorDrawable object, int value) { object.setAlpha(value); }