當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable.setState方法代碼示例

本文整理匯總了Java中android.graphics.drawable.Drawable.setState方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.setState方法的具體用法?Java Drawable.setState怎麽用?Java Drawable.setState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.Drawable的用法示例。


在下文中一共展示了Drawable.setState方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setHotspot

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void setHotspot(Drawable hotspot) {
  if (mHotspot != null) {
    mHotspot.setCallback(null);
    unscheduleDrawable(mHotspot);
  }

  if (hotspot != null) {
    hotspot.setCallback(this);
    if (hotspot.isStateful()) {
      hotspot.setState(getDrawableState());
    }
  }

  mHotspot = hotspot;
  invalidate();
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:17,代碼來源:FlatViewGroup.java

示例2: applyButtonTint

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void applyButtonTint() {
    Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(this.mView);
    if (buttonDrawable == null) {
        return;
    }
    if (this.mHasButtonTint || this.mHasButtonTintMode) {
        buttonDrawable = DrawableCompat.wrap(buttonDrawable).mutate();
        if (this.mHasButtonTint) {
            DrawableCompat.setTintList(buttonDrawable, this.mButtonTintList);
        }
        if (this.mHasButtonTintMode) {
            DrawableCompat.setTintMode(buttonDrawable, this.mButtonTintMode);
        }
        if (buttonDrawable.isStateful()) {
            buttonDrawable.setState(this.mView.getDrawableState());
        }
        this.mView.setButtonDrawable(buttonDrawable);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:AppCompatCompoundButtonHelper.java

示例3: clearDrawableAnimation

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * 清除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();
        }
    }
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:22,代碼來源:CommonUtil.java

示例4: selectBackgroundDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Returns the background drawable for the key, based on the current state and type of the key.
 * @return the background drawable of the key.
 * @see android.graphics.drawable.StateListDrawable#setState(int[])
 */
@Nonnull
public final Drawable selectBackgroundDrawable(@Nonnull final Drawable keyBackground,
        @Nonnull final Drawable functionalKeyBackground,
        @Nonnull final Drawable spacebarBackground) {
    final Drawable background;
    if (mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
        background = functionalKeyBackground;
    } else if (mBackgroundType == BACKGROUND_TYPE_SPACEBAR) {
        background = spacebarBackground;
    } else {
        background = keyBackground;
    }
    final int[] state = KeyBackgroundState.STATES[mBackgroundType].getState(mPressed);
    background.setState(state);
    return background;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:22,代碼來源:Key.java

示例5: setForeground

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Supply a Drawable that is to be rendered on top of all of the child
 * views in the frame layout.  Any padding in the Drawable will be taken
 * into account by ensuring that the children are inset to be placed
 * inside of the padding area.
 *
 * @param drawable The Drawable to be drawn on top of the children.
 */
public void setForeground(View view, Drawable drawable) {
    if (view != null) {
        if (mForeground != drawable) {
            if (mForeground != null) {
                mForeground.setCallback(null);
                view.unscheduleDrawable(mForeground);
            }

            mForeground = drawable;

            if (drawable != null) {
                view.setWillNotDraw(false);
                drawable.setCallback(view);
                if (drawable.isStateful()) {
                    drawable.setState(view.getDrawableState());
                }
                if (mForegroundGravity == Gravity.FILL) {
                    Rect padding = new Rect();
                    drawable.getPadding(padding);
                }

                //update bounds
                updateBounds(view, drawable);//added by song
            } else {
                view.setWillNotDraw(true);
            }
            view.requestLayout();
            view.invalidate();
        }
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:40,代碼來源:ForegroundDelegate.java

示例6: setOrAnimatePlusCheckIcon

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void setOrAnimatePlusCheckIcon(final FloatingActionButton fab, boolean isCheck,
                                      boolean allowAnimate) {
    if (!hasL()) {
        compatSetOrAnimatePlusCheckIcon(fab, isCheck, allowAnimate);
        return;
    }

    Drawable drawable = fab.getDrawable();
    if (!(drawable instanceof AnimatedStateListDrawable)) {
        Resources res = mActivity.getResources();
        drawable = res.getDrawable(R.drawable.add_schedule_fab_icon_anim);
        drawable.setTint(res.getColor(R.color.fab_icon_color));
        fab.setImageDrawable(drawable);
    }

    if (allowAnimate) {
        drawable.setState(isCheck ? STATE_UNCHECKED : STATE_CHECKED);
        drawable.jumpToCurrentState();
        drawable.setState(isCheck ? STATE_CHECKED : STATE_UNCHECKED);
    } else {
        drawable.setState(isCheck ? STATE_CHECKED : STATE_UNCHECKED);
        drawable.jumpToCurrentState();
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:25,代碼來源:LUtils.java

示例7: drawableStateChanged

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();

    final int[] state = getDrawableState();
    boolean changed = false;

    Drawable d = mStatusBarScrim;
    if (d != null && d.isStateful()) {
        changed |= d.setState(state);
    }
    d = mContentScrim;
    if (d != null && d.isStateful()) {
        changed |= d.setState(state);
    }
    if (mCollapsingTextHelper != null) {
        changed |= mCollapsingTextHelper.setState(state);
    }

    if (changed) {
        invalidate();
    }
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:24,代碼來源:QMUICollapsingTopBarLayout.java

示例8: selectBackgroundDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Returns the background drawable for the key, based on the current state and type of the key.
 * @return the background drawable of the key.
 * @see android.graphics.drawable.StateListDrawable#setState(int[])
 */
@NonNull
public final Drawable selectBackgroundDrawable(@NonNull final Drawable keyBackground,
        @NonNull final Drawable functionalKeyBackground,
        @NonNull final Drawable spacebarBackground) {
    final Drawable background;
    if (mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
        background = functionalKeyBackground;
    } else if (mBackgroundType == BACKGROUND_TYPE_SPACEBAR) {
        background = spacebarBackground;
    } else {
        background = keyBackground;
    }
    final int[] state = KeyBackgroundState.STATES[mBackgroundType].getState(mPressed);
    background.setState(state);
    return background;
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:22,代碼來源:Key.java

示例9: drawableStateChanged

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@SuppressWarnings("ConstantConditions")
@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();

    final int[] state = getDrawableState();
    boolean changed = false;

    Drawable d = mStatusBarScrim;
    if (d != null && d.isStateful()) {
        changed |= d.setState(state);
    }
    d = mContentScrim;
    if (d != null && d.isStateful()) {
        changed |= d.setState(state);
    }
    if (mCollapsingTextHelper != null) {
        changed |= mCollapsingTextHelper.setState(state);
    }

    if (changed) {
        invalidate();
    }
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:25,代碼來源:QMUICollapsingTopBarLayout.java

示例10: setForeground

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void setForeground(Drawable drawable) {
	if (mForegroundSelector != drawable) {
		if (mForegroundSelector != null) {
			mForegroundSelector.setCallback(null);
			unscheduleDrawable(mForegroundSelector);
		}

		mForegroundSelector = drawable;

		if (drawable != null) {
			setWillNotDraw(false);
			drawable.setCallback(this);
			if (drawable.isStateful()) {
				drawable.setState(getDrawableState());
			}
		} else {
			setWillNotDraw(true);
		}
		requestLayout();
		invalidate();
	}
}
 
開發者ID:runtimeco,項目名稱:Android-DFU-App,代碼行數:23,代碼來源:ForegroundRelativeLayout.java

示例11: drawableStateChanged

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();

    boolean invalidate = false;
    for (DrawableInfo drawable : mDrawables) {
        Drawable d = drawable.mDrawable;
        if (d.isStateful() && d.setState(getDrawableState())) {
            invalidate = true;
        }
    }

    if (invalidate) {
        invalidate();
    }
}
 
開發者ID:YiiGuxing,項目名稱:CompositionAvatar,代碼行數:17,代碼來源:CompositionAvatarView.java

示例12: drawableStateChanged

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();
    final Drawable d = mMarginDrawable;
    if (d != null && d.isStateful()) {
        d.setState(getDrawableState());
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:DirectionalViewpager.java

示例13: drawableStateChanged

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void drawableStateChanged() {
	super.drawableStateChanged();
	final Drawable d = mMarginDrawable;
	if (d != null && d.isStateful()) {
		d.setState(getDrawableState());
	}
}
 
開發者ID:fengshihao,項目名稱:WebPager,代碼行數:9,代碼來源:CustomViewPager.java

示例14: setDrawableState

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void setDrawableState(Drawable drawable) {
	if (drawable != null) {
		int[] myDrawableState = getDrawableState();
		drawable.setState(myDrawableState);
		invalidate();
	}
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:8,代碼來源:SwitchButton.java

示例15: setSelector

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void setSelector(Drawable sel) {
    if (this.mSelector != null) {
        this.mSelector.setCallback(null);
        unscheduleDrawable(this.mSelector);
    }
    this.mSelector = sel;
    Rect padding = new Rect();
    sel.getPadding(padding);
    this.mSelectionLeftPadding = padding.left;
    this.mSelectionTopPadding = padding.top;
    this.mSelectionRightPadding = padding.right;
    this.mSelectionBottomPadding = padding.bottom;
    sel.setCallback(this);
    sel.setState(getDrawableState());
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:16,代碼來源:PLA_AbsListView.java


注:本文中的android.graphics.drawable.Drawable.setState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。