本文整理汇总了Java中org.holoeverywhere.drawable.StateListDrawable类的典型用法代码示例。如果您正苦于以下问题:Java StateListDrawable类的具体用法?Java StateListDrawable怎么用?Java StateListDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StateListDrawable类属于org.holoeverywhere.drawable包,在下文中一共展示了StateListDrawable类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PopupWindow
import org.holoeverywhere.drawable.StateListDrawable; //导入依赖的package包/类
public PopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
mContext = context;
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PopupWindow, defStyleAttr,
defStyleRes);
mBackground = DrawableCompat
.getDrawable(a, R.styleable.PopupWindow_android_popupBackground);
final int animStyle = a.getResourceId(R.styleable.PopupWindow_android_popupAnimationStyle,
-1);
mAnimationStyle = animStyle == R.style.Holo_Animation_PopupWindow ? -1 : animStyle;
if (mBackground instanceof StateListDrawable) {
StateListDrawable background = (StateListDrawable) mBackground;
int aboveAnchorStateIndex = background.getStateDrawableIndex(ABOVE_ANCHOR_STATE_SET);
int count = background.getStateCount();
int belowAnchorStateIndex = -1;
for (int i = 0; i < count; i++) {
if (i != aboveAnchorStateIndex) {
belowAnchorStateIndex = i;
break;
}
}
if (aboveAnchorStateIndex != -1 && belowAnchorStateIndex != -1) {
mAboveAnchorBackgroundDrawable = background.getStateDrawable(aboveAnchorStateIndex);
mBelowAnchorBackgroundDrawable = background.getStateDrawable(belowAnchorStateIndex);
} else {
mBelowAnchorBackgroundDrawable = null;
mAboveAnchorBackgroundDrawable = null;
}
}
a.recycle();
}
示例2: makeBackgroundDrawable
import org.holoeverywhere.drawable.StateListDrawable; //导入依赖的package包/类
private Drawable makeBackgroundDrawable(Line line) {
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.setExitFadeDuration(150);
stateListDrawable.addState(CHECKED_STATE,
makeColorDrawable(line.getColorResId()));
stateListDrawable.addState(View.EMPTY_STATE_SET,
makeColorDrawable(R.color.translucent_dark_gray));
return stateListDrawable;
}