项目:RoundButton
文件:RoundButton.java
private void update() {
StateListDrawable background = new StateListDrawable();
background.addState(new int[]{android.R.attr.state_pressed},createDrawable(backgroundColorpressed,cornerColorpressed,cornerWidth,cornerRadius));
background.addState(new int[]{-android.R.attr.state_enabled},createDrawable(backgroundColordisabled,cornerColordisabled,cornerRadius));
background.addState(StateSet.WILD_CARD,createDrawable(backgroundColor,cornerColor,cornerRadius));
setBackground(background);
setTextColor(new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_pressed},new int[]{-android.R.attr.state_enabled},new int[]{}
},new int[]{
textColorpressed,textColordisabled,textColor
}
));
}
项目:EasyEmoji
文件:CommonUtil.java
/**
* 清除View(etc:ListView) 拉至顶部或底部的橡皮筋效果
*/
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.nothing);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.nothing);
drawable.jumpToCurrentState();
}
}
}
项目:airgram
文件:AndroidUtilities.java
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.nothing);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.nothing);
drawable.jumpToCurrentState();
}
}
}
项目:android-paypal-example
文件:BadgeDrawableBuilder.java
public StateListDrawable build(Context ctx) {
StateListDrawable stateListDrawable = new StateListDrawable();
GradientDrawable normal = (GradientDrawable) ContextCompat.getDrawable(ctx,R.drawable.action_item_badge);
GradientDrawable selected = (GradientDrawable) normal.getConstantState().newDrawable().mutate();
normal.setColor(mColor);
selected.setColor(mColorpressed);
if (mstroke > -1) {
normal.setstroke(mstroke,mstrokeColor);
selected.setstroke(mstroke,mstrokeColor);
}
if (mCorners > -1) {
normal.setCornerRadius(mCorners);
selected.setCornerRadius(mCorners);
}
stateListDrawable.addState(new int[]{android.R.attr.state_pressed},selected);
stateListDrawable.addState(StateSet.WILD_CARD,normal);
return stateListDrawable;
}
/**
* Extracts state_ attributes from an attribute set.
*
* @param attrs The attribute set.
* @return An array of state_ attributes.
*/
protected int[] extractStateSet(AttributeSet attrs) {
int j = 0;
final int numAttrs = attrs.getAttributeCount();
int[] states = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
if (stateResId == 0) {
break;
} else if (stateResId == android.R.attr.drawable
|| stateResId == android.R.attr.id
|| stateResId == R.attr.drawableTint
|| stateResId == R.attr.drawableTintMode) {
// Ignore attributes from StateListDrawableItem and
// AnimatedStateListDrawableItem.
continue;
} else {
states[j++] = attrs.getAttributeBooleanValue(i,false)
? stateResId : -stateResId;
}
}
states = StateSet.trimstateSet(states,j);
return states;
}
项目:Mix
文件:ColorStateListUtils.java
protected static int[] extractStateSet(AttributeSet attrs) {
int j = 0;
final int numAttrs = attrs.getAttributeCount();
int[] states = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
switch (stateResId) {
case 0:
break;
case android.R.attr.color:
case android.R.attr.alpha:
// Ignore attributes from StateListDrawableItem and
// AnimatedStateListDrawableItem.
continue;
default:
states[j++] = attrs.getAttributeBooleanValue(i,false)
? stateResId : -stateResId;
}
}
states = StateSet.trimstateSet(states,j);
return states;
}
项目:letv
文件:ResourceManager.java
public static StateListDrawable createStateListDrawable(Context context,String normalPicName,String pressedPicName) {
Drawable normalDrawable;
Drawable pressedDrawable;
if (normalPicName.indexOf(".9") > -1) {
normalDrawable = getNinePatchDrawable(context,normalPicName);
} else {
normalDrawable = getDrawable(context,normalPicName);
}
if (pressedPicName.indexOf(".9") > -1) {
pressedDrawable = getNinePatchDrawable(context,pressedPicName);
} else {
pressedDrawable = getDrawable(context,pressedPicName);
}
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{16842919},pressedDrawable);
drawable.addState(new int[]{16842913},pressedDrawable);
drawable.addState(new int[]{16842908},pressedDrawable);
drawable.addState(StateSet.WILD_CARD,normalDrawable);
return drawable;
}
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.nothing);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.nothing);
drawable.jumpToCurrentState();
}
}
}
/**
* Called by View
*/
void setState(int[] state) {
Tuple match = null;
final int count = mTuples.size();
for (int i = 0; i < count; i++) {
final Tuple tuple = mTuples.get(i);
if (StateSet.stateSetMatches(tuple.mSpecs,state)) {
match = tuple;
break;
}
}
if (match == mLastMatch) {
return;
}
if (mLastMatch != null) {
cancel();
}
mLastMatch = match;
if (match != null) {
start(match);
}
}
项目:ChromeLikeTabSwitcher
文件:TabletTabRecyclerAdapter.java
@NonNull
@Override
protected final View onInflateTabView(@NonNull final LayoutInflater inflater,@Nullable final ViewGroup parent,@NonNull final AbstractTabViewHolder viewHolder) {
View view = inflater.inflate(R.layout.tablet_tab,parent,false);
StateListDrawable backgroundDrawable = new StateListDrawable();
Drawable defaultDrawable = ContextCompat
.getDrawable(getModel().getContext(),R.drawable.tablet_tab_background);
Drawable selectedDrawable = ContextCompat
.getDrawable(getModel().getContext(),R.drawable.tablet_tab_background_selected);
backgroundDrawable.addState(new int[]{android.R.attr.state_selected},selectedDrawable);
backgroundDrawable.addState(StateSet.WILD_CARD,defaultDrawable);
ViewUtil.setBackground(view,backgroundDrawable);
return view;
}
项目:PlusGram
文件:AndroidUtilities.java
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.nothing);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.nothing);
drawable.jumpToCurrentState();
}
}
}
void setState(int[] state) {
Tuple match = null;
int count = this.mTuples.size();
for (int i = 0; i < count; i++) {
Tuple tuple = (Tuple) this.mTuples.get(i);
if (StateSet.stateSetMatches(tuple.mSpecs,state)) {
match = tuple;
break;
}
}
if (match != this.mLastMatch) {
if (this.mLastMatch != null) {
cancel();
}
this.mLastMatch = match;
View view = (View) this.mViewRef.get();
if (match != null && view != null && view.getVisibility() == 0) {
start(match);
}
}
}
private void initIdleStateDrawable() {
int colornormal = getnormalColor(mIdleColorState);
int colorpressed = getpressedColor(mIdleColorState);
int colorFocused = getFocusedColor(mIdleColorState);
int colordisabled = getdisabledColor(mIdleColorState);
if (background == null) {
background = createDrawable(colornormal);
}
strokeGradientDrawable drawabledisabled = createDrawable(colordisabled);
strokeGradientDrawable drawableFocused = createDrawable(colorFocused);
strokeGradientDrawable drawablepressed = createDrawable(colorpressed);
mIdleStateDrawable = new StateListDrawable();
mIdleStateDrawable.addState(new int[]{android.R.attr.state_pressed},drawablepressed.getGradientDrawable());
mIdleStateDrawable.addState(new int[]{android.R.attr.state_focused},drawableFocused.getGradientDrawable());
mIdleStateDrawable.addState(new int[]{-android.R.attr.state_enabled},drawabledisabled.getGradientDrawable());
mIdleStateDrawable.addState(StateSet.WILD_CARD,background.getGradientDrawable());
}
项目:OpenEyesReading-android
文件:Util.java
public void setCircleButtonStateListDrawable(View circleButton,int radius,int color) {
WeakReference<Bitmap> imagenormal = new WeakReference<>(Bitmap.createBitmap(2 * radius,2 * radius,Bitmap.Config.ARGB_8888));
Canvas canvasnormal = new Canvas(imagenormal.get());
Paint paintnormal = new Paint();
paintnormal.setAntiAlias(true);
paintnormal.setColor(color);
canvasnormal.drawCircle(radius,radius,paintnormal);
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(StateSet.WILD_CARD,new BitmapDrawable(circleButton.getContext().getResources(),imagenormal.get()));
if (android.os.Build.VERSION.SDK_INT >= 16) {
circleButton.setBackground(stateListDrawable);
} else {
circleButton.setBackgroundDrawable(stateListDrawable);
}
}
/**
* Extracts state_ attributes from an attribute set.
*
* @param attrs The attribute set.
* @return An array of state_ attributes.
*/
static int[] extractStateSet(AttributeSet attrs) {
int j = 0;
final int numAttrs = attrs.getAttributeCount();
int[] states = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
if (stateResId == 0) {
break;
} else if (stateResId == android.R.attr.drawable
|| stateResId == android.R.attr.id
|| stateResId == R.attr.drawableTint
|| stateResId == R.attr.drawableTintMode) {
// Ignore attributes from StateListDrawableItem and
// AnimatedStateListDrawableItem.
continue;
} else {
states[j++] = attrs.getAttributeBooleanValue(i,j);
return states;
}
protected static int[] extractStateSet(AttributeSet attrs) {
int j = 0;
final int numAttrs = attrs.getAttributeCount();
int[] states = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
switch (stateResId) {
case 0:
break;
case android.R.attr.color:
case android.R.attr.alpha:
// Ignore attributes from StateListDrawableItem and
// AnimatedStateListDrawableItem.
continue;
default:
states[j++] = attrs.getAttributeBooleanValue(i,j);
return states;
}
项目:Hyber-SDK-Android
文件:AndroidUtilities.java
@SuppressLint("NewApi")
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.nothing);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.nothing);
drawable.jumpToCurrentState();
}
}
}
项目:permissionsModule
文件:StateListAnimator.java
/**
* Called by View
*/
void setState(int[] state) {
Tuple match = null;
final int count = mTuples.size();
for (int i = 0; i < count; i++) {
final Tuple tuple = mTuples.get(i);
if (StateSet.stateSetMatches(tuple.mSpecs,state)) {
match = tuple;
break;
}
}
if (match == mLastMatch) {
return;
}
if (mLastMatch != null) {
cancel();
}
mLastMatch = match;
View view = mViewRef.get();
if (match != null && view != null && view.getVisibility() == View.VISIBLE ) {
start(match);
}
}
private void initIdleStateDrawable() {
int colornormal = getnormalColor(mIdleColorState);
int colorpressed = getpressedColor(mIdleColorState);
int colorFocused = getFocusedColor(mIdleColorState);
int colordisabled = getdisabledColor(mIdleColorState);
if (background == null) {
background = createDrawable(colornormal);
}
strokeGradientDrawable drawabledisabled = createDrawable(colordisabled);
strokeGradientDrawable drawableFocused = createDrawable(colorFocused);
strokeGradientDrawable drawablepressed = createDrawable(colorpressed);
mIdleStateDrawable = new StateListDrawable();
mIdleStateDrawable.addState(new int[]{android.R.attr.state_pressed},background.getGradientDrawable());
}
项目:AndroidActionItemBadge
文件:BadgeDrawableBuilder.java
public StateListDrawable build(Context ctx) {
StateListDrawable stateListDrawable = new StateListDrawable();
GradientDrawable normal = (GradientDrawable) UIUtil.getCompatDrawable(ctx,R.drawable.action_item_badge);
GradientDrawable selected = (GradientDrawable) normal.getConstantState().newDrawable().mutate();
normal.setColor(mColor);
selected.setColor(mColorpressed);
if (mCorners > -1) {
normal.setCornerRadius(mCorners);
selected.setCornerRadius(mCorners);
}
stateListDrawable.addState(new int[]{android.R.attr.state_pressed},normal);
return stateListDrawable;
}
项目:material-components-android
文件:StateListAnimator.java
/** Called by View */
void setState(int[] state) {
Tuple match = null;
final int count = tuples.size();
for (int i = 0; i < count; i++) {
final Tuple tuple = tuples.get(i);
if (StateSet.stateSetMatches(tuple.specs,state)) {
match = tuple;
break;
}
}
if (match == lastMatch) {
return;
}
if (lastMatch != null) {
cancel();
}
lastMatch = match;
if (match != null) {
start(match);
}
}
private void initIdleStateDrawable() {
int colornormal = getnormalColor(mIdleColorState);
int colorpressed = getpressedColor(mIdleColorState);
int colorFocused = getFocusedColor(mIdleColorState);
int colordisabled = getdisabledColor(mIdleColorState);
if (background == null) {
background = createDrawable(colornormal);
}
strokeGradientDrawable drawabledisabled = createDrawable(colordisabled);
strokeGradientDrawable drawableFocused = createDrawable(colorFocused);
strokeGradientDrawable drawablepressed = createDrawable(colorpressed);
mIdleStateDrawable = new StateListDrawable();
mIdleStateDrawable.addState(new int[]{android.R.attr.state_pressed},background.getGradientDrawable());
}
项目:MaterialDrawer
文件:BadgeDrawableBuilder.java
public StateListDrawable build(Context ctx) {
StateListDrawable stateListDrawable = new StateListDrawable();
GradientDrawable normal = (GradientDrawable) UIUtils.getCompatDrawable(ctx,mStyle.getGradientDrawable());
GradientDrawable selected = (GradientDrawable) normal.getConstantState().newDrawable().mutate();
ColorHolder.applyToOrTransparent(mStyle.getColor(),ctx,normal);
if (mStyle.getColorpressed() == null) {
ColorHolder.applyToOrTransparent(mStyle.getColor(),selected);
} else {
ColorHolder.applyToOrTransparent(mStyle.getColorpressed(),selected);
}
if (mStyle.getCorners() != null) {
normal.setCornerRadius(mStyle.getCorners().asPixel(ctx));
selected.setCornerRadius(mStyle.getCorners().asPixel(ctx));
}
stateListDrawable.addState(new int[]{android.R.attr.state_pressed},normal);
return stateListDrawable;
}
项目:YouJoin-Android
文件:BadgeDrawableBuilder.java
项目:hill-lists
文件:FolderPicker.java
@Override
protected boolean onStateChange(int[] state) {
boolean active = StateSet.stateSetMatches(STATE_SELECTED,state) | StateSet.stateSetMatches(STATE_pressed,state);
if (active != mActive) {
mActive = active;
// Log.d("FolderTransitionDrawable","onStateChange " + StateSet.dump(state) + " " + active);
if (!active) {
unscheduleSelf(this);
if (mAlpha != 255) {
startTransition(false);
}
} else {
scheduleSelf(this,SystemClock.uptimeMillis() + 500);
}
return true;
}
return false;
}
项目:FMTech
文件:ToolButton.java
@Deprecated
public final void a(int paramInt1,int paramInt2,int paramInt3)
{
if (paramInt1 == 0) {
return;
}
Resources localResources = getResources();
StateListDrawable localStateListDrawable = new StateListDrawable();
if (paramInt2 != 0)
{
Drawable localDrawable2 = localResources.getDrawable(paramInt2);
localStateListDrawable.addState(new int[] { 16842910,16842913 },localDrawable2);
}
Drawable localDrawable1 = localResources.getDrawable(paramInt1);
if (paramInt3 == 0) {}
for (Object localObject = a(localDrawable1);; localObject = localResources.getDrawable(paramInt3))
{
localStateListDrawable.addState(new int[] { -16842910 },(Drawable)localObject);
localStateListDrawable.addState(new int[] { -16842910,(Drawable)localObject);
localStateListDrawable.addState(StateSet.WILD_CARD,localDrawable1);
this.a.setimageDrawable(localStateListDrawable);
return;
}
}
项目:Carbon
文件:AnimatedColorStateList.java
public void setState(int[] newState) {
if (Arrays.equals(newState,currentState))
return;
if (currentState != null)
cancel();
for (final int[] state : states) {
if (StateSet.stateSetMatches(state,newState)) {
int firstColor = super.getColorForState(currentState,getDefaultColor());
int secondColor = super.getColorForState(newState,getDefaultColor());
colorAnimation.setIntValues(firstColor,secondColor);
currentState = newState;
animatedColor = firstColor;
colorAnimation.start();
return;
}
}
currentState = newState;
}
项目:Carbon
文件:StateAnimator.java
/**
* Called by View
*/
public void setState(int[] state) {
Tuple match = null;
final int count = mTuples.size();
for (int i = 0; i < count; i++) {
final Tuple tuple = mTuples.get(i);
if (StateSet.stateSetMatches(tuple.mSpecs,state)) {
match = tuple;
break;
}
}
if (match == lastMatch) {
return;
}
if (lastMatch != null) {
cancel();
}
lastMatch = match;
View view = (View) viewRef.get();
if (match != null && view != null && view.getVisibility() == View.VISIBLE) {
start(match);
}
}
项目:alternate-java-bridge-library
文件:TabForm.java
/**
* Use this method to add a Tab to the tabForm. Each tab is it's own
* Form.
*
* @param title The title of the tab
* @param selected - The selected drawable image ( use something like "image42" ) of the tab icon
* @param notselected - The not selected drawable image of the tab icon
* @param formtoopen - The Form to open in this tab's space
*/
public void addTab(String title,String selected,String notselected,Class<?> formtoopen) {
int[] temp = new int[2];
temp[0] = getResources().getIdentifier(selected,"drawable",getPackageName());
temp[1] = getResources().getIdentifier(notselected,getPackageName());
StateListDrawable draw = new StateListDrawable();
BitmapDrawable draw1 = (BitmapDrawable) getResources().getDrawable(temp[0]);
BitmapDrawable draw2 = (BitmapDrawable) getResources().getDrawable(temp[1]);
draw.addState(new int[] {android.R.attr.state_selected},draw1);
draw.addState(StateSet.WILD_CARD,draw2);
Intent intent = new Intent().setClass(this,formtoopen);
TabHost.TabSpec spec;
spec = tabHost.newTabSpec(title.toLowerCase()).setIndicator(title,draw).setContent(intent);
tabHost.addTab(spec);
}
项目:alternate-java-bridge-library
文件:TabForm.java
/**
* Use this method to add a Tab to the tabForm. Each tab is it's own
* Form.
*
* @param title The title of the tab
* @param selected - The resourceId of the selected tab icon
* @param notselected - The resourceId of the not selected tab icon
* @param formtoopen - The Form to open in this tab's space
*/
public void addTab(String title,int selectedresId,int notselectedresId,Class<?> formtoopen) {
int[] temp = new int[2];
temp[0] = selectedresId;
temp[1] = notselectedresId;
StateListDrawable draw = new StateListDrawable();
BitmapDrawable draw1 = (BitmapDrawable) getResources().getDrawable(temp[0]);
BitmapDrawable draw2 = (BitmapDrawable) getResources().getDrawable(temp[1]);
draw.addState(new int[] {android.R.attr.state_selected},draw).setContent(intent);
tabHost.addTab(spec);
}
项目:digits-android
文件:ButtonThemer.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
void setBackgroundAccentColor(View view,int accentColor) {
final StateListDrawable background = new StateListDrawable();
final float radius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,5,resources.getdisplayMetrics());
// pressed or in focus
GradientDrawable tmp = new GradientDrawable();
tmp.setCornerRadius(radius);
tmp.setColor(getpressedColor(accentColor));
for (int[]state: focussedOrpressedButEnabled) {
background.addState(state,tmp);
}
// default
tmp = new GradientDrawable();
tmp.setColor(accentColor);
tmp.setCornerRadius(radius);
background.addState(StateSet.WILD_CARD,tmp);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.setBackground(background);
} else {
view.setBackgroundDrawable(background);
}
}
项目:digits-android
文件:ButtonThemer.java
void setTextAccentColorInverse(TextView view,int accentColor) {
final int pressedColor = getpressedColor(accentColor);
final int disabledColor = getdisabledColor(accentColor);
final int[][] states = new int[][]{
new int[]{android.R.attr.state_pressed,android.R.attr.state_enabled},new int[]{android.R.attr.state_focused,StateSet.WILD_CARD
};
final int[] colors = new int[]{pressedColor,pressedColor,disabledColor,accentColor};
final ColorStateList stateList = new ColorStateList(states,colors);
view.setTextColor(stateList);
}
项目:DenleyBihari
文件:DrawerListItem.java
/**
* Sets up the background drawable for this list item.
*
* This must be done programatically,to use the theme-dependent background attribute
* as a fallback for the "pressed" and "normal" states.
*/
private void setupBackground(final Context context){
// Load the "normal" state,a theme attribute
final TypedArray backgroundarray = context.obtainStyledAttributes(
new int[]{R.attr.selectableItemBackground});
final Drawable normalpressedBackground = backgroundarray.getDrawable(0);
backgroundarray.recycle();
// Load the "selected" state
final Drawable selectedBackground = new ColorDrawable(
context.getResources().getColor(R.color.selected_item_background));
// Set up the state-list drawable
final StateListDrawable background = new StateListDrawable();
background.addState(new int[]{android.R.attr.state_selected},selectedBackground);
background.addState(StateSet.WILD_CARD,normalpressedBackground);
setBackgroundDrawable(background);
}
项目:multi-seek-bar
文件:AbsMultiSeekBar.java
public static ColorStateList generateDefaultTrackColorStateListFromTheme(Context context) {
int[][] states = new int[][] {
SELECTED_STATE_SET,ENABLED_STATE_SET,StateSet.WILD_CARD
};
// This is an approximation of the track colors derived from Lollipop resources
boolean isLightTheme = Utils.isLightTheme(context);
int enabled = isLightTheme ? 0x28181818 : 0x85ffffff;
int[] colors = new int[] {
Utils.getThemeColor(context,android.R.attr.colorControlActivated),enabled,0x14181818 //Todo: get this from a theme attr?
};
return new ColorStateList(states,colors);
}
项目:yelo-android
文件:AndroidUtilities.java
public static void clearDrawableAnimation(View view) {
if (Build.VERSION.SDK_INT < 21 || view == null) {
return;
}
Drawable drawable = null;
if (view instanceof ListView) {
drawable = ((ListView) view).getSelector();
if (drawable != null) {
drawable.setState(StateSet.nothing);
}
} else {
drawable = view.getBackground();
if (drawable != null) {
drawable.setState(StateSet.nothing);
drawable.jumpToCurrentState();
}
}
}
private static ColorStateList createIndetermcolorStateList(Context context) {
final int[][] states = new int[][]{
new int[]{-android.R.attr.state_enabled},new int[]{R.attr.state_indeterminate},new int[]{android.R.attr.state_checked},StateSet.WILD_CARD
};
final int normal = resolveColor(context,R.attr.colorControlnormal,Color.DKGRAY);
final int activated = resolveColor(context,R.attr.colorControlActivated,Color.CYAN);
final float disabledAlpha = resolveFloat(context,android.R.attr.disabledAlpha,0.25f);
final int[] colors = new int[]{
Utils.applyAlpha(normal,disabledAlpha),normal,activated,normal
};
return new ColorStateList(states,colors);
}
项目:actor-platform
文件:ComposeFabFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState) {
View res = inflater.inflate(R.layout.fragment_fab,container,false);
FloatingActionButton fabroot = (FloatingActionButton) res.findViewById(R.id.fab);
fabroot.setimageResource(R.drawable.ic_edit_white_24dp);
fabroot.setBackgroundTintList(new ColorStateList(new int[][]{
new int[]{android.R.attr.state_pressed},StateSet.WILD_CARD,},new int[]{
ActorSDK.sharedActor().style.getFabpressedColor(),ActorSDK.sharedActor().style.getFabColor(),}));
fabroot.setRippleColor(ActorSDK.sharedActor().style.getFabpressedColor());
fabroot.setonClickListener(v -> startActivity(new Intent(getActivity(),ComposeActivity.class)));
return res;
}
private void initIdleStateDrawable() {
int colornormal = getnormalColor(mIdleColorState);
int colorpressed = getpressedColor(mIdleColorState);
int colorFocused = getFocusedColor(mIdleColorState);
int colordisabled = getdisabledColor(mIdleColorState);
if (background == null) {
background = createDrawable(colornormal);
}
strokeGradientDrawable drawabledisabled = createDrawable(colordisabled);
strokeGradientDrawable drawableFocused = createDrawable(colorFocused);
strokeGradientDrawable drawablepressed = createDrawable(colorpressed);
mIdleStateDrawable = new StateListDrawable();
mIdleStateDrawable.addState(new int[]{android.R.attr.state_pressed},background.getGradientDrawable());
}
项目:MaterialDrawer-Xamarin
文件:BadgeDrawableBuilder.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。