本文整理匯總了Java中android.graphics.drawable.Drawable.setAlpha方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.setAlpha方法的具體用法?Java Drawable.setAlpha怎麽用?Java Drawable.setAlpha使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.setAlpha方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: disableDays
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
* This view disables tapping on the day objects and on the endDate label. It also
* colors them following the material design specification.
*/
private void disableDays() {
double opacity = 0.26; //Following the material specification, disabled buttons have opacity 26%
for (int i = 0; i < weekdaysSelection.length; i++) {
LinearLayout day = getDayLayout(i);
day.setOnClickListener(null);
endDateTextView.setOnClickListener(null);
endDateTextView.setAlpha( (float) (opacity * 255 /100));
int colorBlack = ContextCompat.getColor(getBaseContext(), R.color.black);
if (day.getBackground()== null) {
Drawable bg = ContextCompat.getDrawable(getBaseContext(), R.drawable.circle_step);
bg.setColorFilter(new PorterDuffColorFilter(colorBlack, PorterDuff.Mode.SRC_IN));
bg.setAlpha((int) (opacity * 255));
day.setBackground(bg);
} else {
day.getBackground().setColorFilter(new PorterDuffColorFilter(colorBlack, PorterDuff.Mode.SRC_IN));
day.getBackground().setAlpha((int) (opacity * 255));
}
}
}
示例2: colorMenuItem
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
* Sets the color filter and/or the alpha transparency on a {@link MenuItem}'s icon.
*
* @param menuItem The {@link MenuItem} to theme.
* @param color The color to set for the color filter or {@code null} for no changes.
* @param alpha The alpha value (0...255) to set on the icon or {@code null} for no changes.
*/
public static void colorMenuItem(MenuItem menuItem, Integer color, Integer alpha) {
if (color == null && alpha == null) {
return; // nothing to do.
}
Drawable drawable = menuItem.getIcon();
if (drawable != null) {
// If we don't mutate the drawable, then all drawables with this id will have the ColorFilter
drawable.mutate();
if (color != null) {
drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
if (alpha != null) {
drawable.setAlpha(alpha);
}
}
}
示例3: getPressedStateDrawable
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static Drawable getPressedStateDrawable(Context context, @PressedMode.Mode int mode, @FloatRange(from = 0.0f, to = 1.0f) float alpha, @NonNull Drawable pressed) {
//ColorDrawable is not supported on 4.4 because the size of the ColorDrawable can not be determined unless the View size is passed in
if (isKitkat() && !(pressed instanceof ColorDrawable)) {
return kitkatDrawable(context, pressed, mode, alpha);
}
switch (mode) {
case PressedMode.ALPHA:
pressed.setAlpha(convertAlphaToInt(alpha));
break;
case PressedMode.DARK:
pressed.setColorFilter(alphaColor(Color.BLACK, convertAlphaToInt(alpha)), PorterDuff.Mode.SRC_ATOP);
break;
default:
pressed.setAlpha(convertAlphaToInt(alpha));
}
return pressed;
}
示例4: setColors
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void setColors(int mainColor, int frameColor, int chargeColor) {
if (mBattery != null) {
try {
Object drawable = getDrawable();
final int[] colors = (int[]) XposedHelpers.getObjectField(drawable, "mColors");
colors[colors.length - 1] = mainColor;
if (Utils.isLineageOs()) {
Drawable frameDrawable = (Drawable) XposedHelpers.getObjectField(drawable, "mFrameDrawable");
frameDrawable.setAlpha(mFrameAlpha);
frameDrawable.setTint(frameColor);
Paint paint = (Paint) XposedHelpers.getObjectField(drawable, "mTextAndBoltPaint");
paint.setColor(chargeColor);
} else {
final Paint framePaint = (Paint) XposedHelpers.getObjectField(drawable, "mFramePaint");
framePaint.setColor(frameColor);
framePaint.setAlpha(mFrameAlpha);
XposedHelpers.setIntField(drawable, "mChargeColor", chargeColor);
}
XposedHelpers.setIntField(drawable, "mIconTint", mainColor);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
}
示例5: applyDim
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void applyDim(Activity activity) {
ViewGroup parent = (ViewGroup) activity.getWindow().getDecorView().getRootView();
//activity跟布局
// ViewGroup parent = (ViewGroup) parent1.getChildAt(0);
Drawable dim = new ColorDrawable(mDimColor);
dim.setBounds(0, 0, parent.getWidth(), parent.getHeight());
dim.setAlpha((int) (255 * mDimValue));
ViewGroupOverlay overlay = parent.getOverlay();
overlay.add(dim);
}
示例6: ActionSheet
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public ActionSheet(Context context) {
super(context, android.R.style.Theme_Light_NoTitleBar);// 全屏
this.mContext = context;
initViews();
getWindow().setGravity(Gravity.BOTTOM);
Drawable drawable = new ColorDrawable();
drawable.setAlpha(0);// 去除黑色背景
getWindow().setBackgroundDrawable(drawable);
}
示例7: transform
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public void transform(Drawable drawable, WheelView.ItemState itemState) {
float relativePosition = Math.abs(itemState.getRelativePosition());
int alpha = (int) ((1f - Math.pow(relativePosition, 2.5f)) * 255f);
//clamp to between 0 and 255
if (alpha > 255) alpha = 255;
else if (alpha < 0) alpha = 0;
drawable.setAlpha(alpha);
}
示例8: displayRemoteProvisioningInProgressDialog
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void displayRemoteProvisioningInProgressDialog() {
remoteProvisioningInProgress = true;
progress = ProgressDialog.show(this, null, null);
Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorE));
d.setAlpha(200);
progress.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
progress.getWindow().setBackgroundDrawable(d);
progress.setContentView(R.layout.progress_dialog);
progress.show();
}
示例9: displayDialog
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public Dialog displayDialog(String text){
Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorC));
d.setAlpha(200);
dialog.setContentView(R.layout.dialog);
dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(d);
TextView customText = (TextView) dialog.findViewById(R.id.customText);
customText.setText(text);
return dialog;
}
示例10: QActionSheet
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public QActionSheet(QActionSheet.Builder builder) {
super(builder.context, android.R.style.Theme_Light_NoTitleBar);
Drawable drawable = new ColorDrawable();
drawable.setAlpha(0);
getWindow().setBackgroundDrawable(drawable);
this.items = builder.items;
this.initialSelection = builder.initialSelection;
this.title = builder.title;
this.onItemSelectListener = builder.listener;
initView();
initItemViews();
}
示例11: getIcon
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Nullable
public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) {
final OptionalAttributes attrs = mOptionalAttributes;
final int disabledIconId = (attrs != null) ? attrs.mDisabledIconId : ICON_UNDEFINED;
final int iconId = mEnabled ? getIconId() : disabledIconId;
final Drawable icon = iconSet.getIconDrawable(iconId);
if (icon != null) {
icon.setAlpha(alpha);
}
return icon;
}
示例12: applyWallpaperDim
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public static void applyWallpaperDim(Activity activity) {
Drawable background = new ColorDrawable(Color.BLACK);
int dim = SharedPrefUtils.getInt(activity, KEY_WALLPAPER_DIM);
int alpha = Math.round((float) dim / MAX_WALLPAPER_DIM * 255);
background.setAlpha(alpha);
activity.getWindow().setBackgroundDrawable(background);
}
示例13: getUnableStateDrawable
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private static Drawable getUnableStateDrawable(Context context, @NonNull Drawable unable) {
if (isKitkat() && !(unable instanceof ColorDrawable)) {
return kitkatUnableDrawable(context, unable);
}
unable.setAlpha(convertAlphaToInt(0.5f));
return unable;
}
示例14: applyTransformation
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
mCurrentAlpha = mFromAlpha + ((mToAlpha - mFromAlpha) * interpolatedTime);
if (FLAG_FLADE_FLOAT == (FLAG_FLADE_FLOAT & mFlag)) {
Drawable drawable = getFadeDrawable();
drawable.setAlpha((int) (255 * (1 - mCurrentAlpha)));
invalidate();
} else {
mCurrentAlpha = mCurrentAlpha * mCurrentAlpha;
setAlpha(mCurrentAlpha);
}
}
示例15: themeChange
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public void themeChange(ThemeEnum themeEnum, int[] colors) {
int[] cs2 = ColorUtils.get2ActionStatusBarColors(this);
int actionC = cs2[0];
int statusC = cs2[1];
toolbar.setBackgroundColor(statusC);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(actionC);
}
ThemeEnum theme = appPreference.getTheme();
int[] cs = ColorUtils.get10ThemeColors(this, theme);
int vicBC = theme == ThemeEnum.WHITE ? Color.WHITE : cs[4];
int mainTC = cs[5];
int vicTC = cs[6];
guide.setTextColor(mainTC);
star.setTextColor(mainTC);
share.setTextColor(mainTC);
name.setTextColor(vicTC);
version.setTextColor(mainTC);
container.setBackgroundColor(vicBC);
Drawable d;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
d = getDrawable(R.drawable.ic_navigate_next);
d.setTint(vicTC);
} else {
d = getResources().getDrawable(R.drawable.ic_navigate_next);
}
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
d.setAlpha(150);
guide.setCompoundDrawables(null, null, d, null);
star.setCompoundDrawables(null, null, d, null);
share.setCompoundDrawables(null, null, d, null);
}