Search in sources :

Example 81 with Drawable

use of android.graphics.drawable.Drawable in project android_frameworks_base by ParanoidAndroid.

the class SizeAdaptiveLayout method initialize.

private void initialize() {
    mModestyPanel = new View(getContext());
    // If the SizeAdaptiveLayout has a solid background, use it as a transition hint.
    Drawable background = getBackground();
    if (background instanceof StateListDrawable) {
        StateListDrawable sld = (StateListDrawable) background;
        sld.setState(StateSet.WILD_CARD);
        background = sld.getCurrent();
    }
    if (background instanceof ColorDrawable) {
        mModestyPanel.setBackgroundDrawable(background);
    } else {
        mModestyPanel.setBackgroundColor(Color.BLACK);
    }
    SizeAdaptiveLayout.LayoutParams layout = new SizeAdaptiveLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mModestyPanel.setLayoutParams(layout);
    addView(mModestyPanel);
    mFadePanel = ObjectAnimator.ofFloat(mModestyPanel, "alpha", 0f);
    mFadeView = ObjectAnimator.ofFloat(null, "alpha", 0f);
    mAnimatorListener = new BringToFrontOnEnd();
    mTransitionAnimation = new AnimatorSet();
    mTransitionAnimation.play(mFadeView).with(mFadePanel);
    mTransitionAnimation.setDuration(CROSSFADE_TIME);
    mTransitionAnimation.addListener(mAnimatorListener);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) AnimatorSet(android.animation.AnimatorSet) StateListDrawable(android.graphics.drawable.StateListDrawable) RemoteView(android.widget.RemoteViews.RemoteView) View(android.view.View)

Example 82 with Drawable

use of android.graphics.drawable.Drawable in project android_frameworks_base by ParanoidAndroid.

the class IconMenuView method onDraw.

@Override
protected void onDraw(Canvas canvas) {
    Drawable drawable = mHorizontalDivider;
    if (drawable != null) {
        // If we have a horizontal divider to draw, draw it at the remembered positions
        final ArrayList<Rect> rects = mHorizontalDividerRects;
        for (int i = rects.size() - 1; i >= 0; i--) {
            drawable.setBounds(rects.get(i));
            drawable.draw(canvas);
        }
    }
    drawable = mVerticalDivider;
    if (drawable != null) {
        // If we have a vertical divider to draw, draw it at the remembered positions
        final ArrayList<Rect> rects = mVerticalDividerRects;
        for (int i = rects.size() - 1; i >= 0; i--) {
            drawable.setBounds(rects.get(i));
            drawable.draw(canvas);
        }
    }
}
Also used : Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable)

Example 83 with Drawable

use of android.graphics.drawable.Drawable in project android_frameworks_base by ParanoidAndroid.

the class GlowPadView method startBackgroundAnimation.

private void startBackgroundAnimation(int duration, float alpha) {
    final Drawable background = getBackground();
    if (mAlwaysTrackFinger && background != null) {
        if (mBackgroundAnimator != null) {
            mBackgroundAnimator.animator.cancel();
        }
        mBackgroundAnimator = Tweener.to(background, duration, "ease", Ease.Cubic.easeIn, "alpha", (int) (255.0f * alpha), "delay", SHOW_ANIMATION_DELAY);
        mBackgroundAnimator.animator.start();
    }
}
Also used : Drawable(android.graphics.drawable.Drawable)

Example 84 with Drawable

use of android.graphics.drawable.Drawable in project android_frameworks_base by ParanoidAndroid.

the class View method initializeScrollbars.

/**
     * <p>
     * Initializes the scrollbars from a given set of styled attributes. This
     * method should be called by subclasses that need scrollbars and when an
     * instance of these subclasses is created programmatically rather than
     * being inflated from XML. This method is automatically called when the XML
     * is inflated.
     * </p>
     *
     * @param a the styled attributes set to initialize the scrollbars from
     */
protected void initializeScrollbars(TypedArray a) {
    initScrollCache();
    final ScrollabilityCache scrollabilityCache = mScrollCache;
    if (scrollabilityCache.scrollBar == null) {
        scrollabilityCache.scrollBar = new ScrollBarDrawable();
    }
    final boolean fadeScrollbars = a.getBoolean(R.styleable.View_fadeScrollbars, true);
    if (!fadeScrollbars) {
        scrollabilityCache.state = ScrollabilityCache.ON;
    }
    scrollabilityCache.fadeScrollBars = fadeScrollbars;
    scrollabilityCache.scrollBarFadeDuration = a.getInt(R.styleable.View_scrollbarFadeDuration, ViewConfiguration.getScrollBarFadeDuration());
    scrollabilityCache.scrollBarDefaultDelayBeforeFade = a.getInt(R.styleable.View_scrollbarDefaultDelayBeforeFade, ViewConfiguration.getScrollDefaultDelay());
    scrollabilityCache.scrollBarSize = a.getDimensionPixelSize(com.android.internal.R.styleable.View_scrollbarSize, ViewConfiguration.get(mContext).getScaledScrollBarSize());
    Drawable track = a.getDrawable(R.styleable.View_scrollbarTrackHorizontal);
    scrollabilityCache.scrollBar.setHorizontalTrackDrawable(track);
    Drawable thumb = a.getDrawable(R.styleable.View_scrollbarThumbHorizontal);
    if (thumb != null) {
        scrollabilityCache.scrollBar.setHorizontalThumbDrawable(thumb);
    }
    boolean alwaysDraw = a.getBoolean(R.styleable.View_scrollbarAlwaysDrawHorizontalTrack, false);
    if (alwaysDraw) {
        scrollabilityCache.scrollBar.setAlwaysDrawHorizontalTrack(true);
    }
    track = a.getDrawable(R.styleable.View_scrollbarTrackVertical);
    scrollabilityCache.scrollBar.setVerticalTrackDrawable(track);
    thumb = a.getDrawable(R.styleable.View_scrollbarThumbVertical);
    if (thumb != null) {
        scrollabilityCache.scrollBar.setVerticalThumbDrawable(thumb);
    }
    alwaysDraw = a.getBoolean(R.styleable.View_scrollbarAlwaysDrawVerticalTrack, false);
    if (alwaysDraw) {
        scrollabilityCache.scrollBar.setAlwaysDrawVerticalTrack(true);
    }
    // Apply layout direction to the new Drawables if needed
    final int layoutDirection = getLayoutDirection();
    if (track != null) {
        track.setLayoutDirection(layoutDirection);
    }
    if (thumb != null) {
        thumb.setLayoutDirection(layoutDirection);
    }
    // Re-apply user/background padding so that scrollbar(s) get added
    resolvePadding();
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) ScrollBarDrawable(android.widget.ScrollBarDrawable) ScrollBarDrawable(android.widget.ScrollBarDrawable) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 85 with Drawable

use of android.graphics.drawable.Drawable in project android_frameworks_base by ParanoidAndroid.

the class FrameLayout method onMeasure.

/**
     * {@inheritDoc}
     */
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int count = getChildCount();
    final boolean measureMatchParentChildren = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY || MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY;
    mMatchParentChildren.clear();
    int maxHeight = 0;
    int maxWidth = 0;
    int childState = 0;
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (mMeasureAllChildren || child.getVisibility() != GONE) {
            measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            maxWidth = Math.max(maxWidth, child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
            maxHeight = Math.max(maxHeight, child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
            childState = combineMeasuredStates(childState, child.getMeasuredState());
            if (measureMatchParentChildren) {
                if (lp.width == LayoutParams.MATCH_PARENT || lp.height == LayoutParams.MATCH_PARENT) {
                    mMatchParentChildren.add(child);
                }
            }
        }
    }
    // Account for padding too
    maxWidth += getPaddingLeftWithForeground() + getPaddingRightWithForeground();
    maxHeight += getPaddingTopWithForeground() + getPaddingBottomWithForeground();
    // Check against our minimum height and width
    maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
    maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
    // Check against our foreground's minimum height and width
    final Drawable drawable = getForeground();
    if (drawable != null) {
        maxHeight = Math.max(maxHeight, drawable.getMinimumHeight());
        maxWidth = Math.max(maxWidth, drawable.getMinimumWidth());
    }
    setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState), resolveSizeAndState(maxHeight, heightMeasureSpec, childState << MEASURED_HEIGHT_STATE_SHIFT));
    count = mMatchParentChildren.size();
    if (count > 1) {
        for (int i = 0; i < count; i++) {
            final View child = mMatchParentChildren.get(i);
            final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
            int childWidthMeasureSpec;
            int childHeightMeasureSpec;
            if (lp.width == LayoutParams.MATCH_PARENT) {
                childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth() - getPaddingLeftWithForeground() - getPaddingRightWithForeground() - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY);
            } else {
                childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, getPaddingLeftWithForeground() + getPaddingRightWithForeground() + lp.leftMargin + lp.rightMargin, lp.width);
            }
            if (lp.height == LayoutParams.MATCH_PARENT) {
                childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight() - getPaddingTopWithForeground() - getPaddingBottomWithForeground() - lp.topMargin - lp.bottomMargin, MeasureSpec.EXACTLY);
            } else {
                childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, getPaddingTopWithForeground() + getPaddingBottomWithForeground() + lp.topMargin + lp.bottomMargin, lp.height);
            }
            child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
        }
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) RemoteView(android.widget.RemoteViews.RemoteView) View(android.view.View)

Aggregations

Drawable (android.graphics.drawable.Drawable)2687 BitmapDrawable (android.graphics.drawable.BitmapDrawable)522 View (android.view.View)311 ColorDrawable (android.graphics.drawable.ColorDrawable)275 Bitmap (android.graphics.Bitmap)242 ImageView (android.widget.ImageView)226 TextView (android.widget.TextView)215 Paint (android.graphics.Paint)213 LayerDrawable (android.graphics.drawable.LayerDrawable)209 Rect (android.graphics.Rect)203 StateListDrawable (android.graphics.drawable.StateListDrawable)152 Resources (android.content.res.Resources)140 AnimationDrawable (android.graphics.drawable.AnimationDrawable)137 PackageManager (android.content.pm.PackageManager)126 Context (android.content.Context)122 TypedArray (android.content.res.TypedArray)113 ClipDrawable (android.graphics.drawable.ClipDrawable)108 Test (org.junit.Test)100 ViewGroup (android.view.ViewGroup)99 ShapeDrawable (android.graphics.drawable.ShapeDrawable)94