Example usage for android.graphics.drawable Drawable getMinimumHeight

List of usage examples for android.graphics.drawable Drawable getMinimumHeight

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable getMinimumHeight.

Prototype

public int getMinimumHeight() 

Source Link

Document

Returns the minimum height suggested by this Drawable.

Usage

From source file:connect.app.com.connect.calendar.DayPickerViewPager.java

@TargetApi(Build.VERSION_CODES.M)
@Override/*from  w ww .j a v a 2  s  .c om*/
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    //        populate();

    // Everything below is mostly copied from FrameLayout.
    int count = getChildCount();

    final boolean measureMatchParentChildren = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY
            || MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY;

    int maxHeight = 0;
    int maxWidth = 0;
    int childState = 0;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            measureChild(child, widthMeasureSpec, heightMeasureSpec);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            maxWidth = Math.max(maxWidth, child.getMeasuredWidth());
            maxHeight = Math.max(maxHeight, child.getMeasuredHeight());
            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 += getPaddingLeft() + getPaddingRight();
    maxHeight += getPaddingTop() + getPaddingBottom();

    // 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 LayoutParams lp = (LayoutParams) child.getLayoutParams();
            final int childWidthMeasureSpec;
            final int childHeightMeasureSpec;

            if (lp.width == LayoutParams.MATCH_PARENT) {
                childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
                        getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
            } else {
                childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
                        getPaddingLeft() + getPaddingRight(), lp.width);
            }

            if (lp.height == LayoutParams.MATCH_PARENT) {
                childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
                        getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY);
            } else {
                childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
                        getPaddingTop() + getPaddingBottom(), lp.height);
            }

            child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
        }
    }

    mMatchParentChildren.clear();
}

From source file:com.tr4android.support.extension.picker.date.DialogViewAnimator.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final boolean measureMatchParentChildren = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY
            || MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY;

    int maxHeight = 0;
    int maxWidth = 0;
    int childState = 0;

    // First measure all children and record maximum dimensions where the
    // spec isn't MATCH_PARENT.
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (getMeasureAllChildren() || child.getVisibility() != GONE) {
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            final boolean matchWidth = lp.width == LayoutParams.MATCH_PARENT;
            final boolean matchHeight = lp.height == LayoutParams.MATCH_PARENT;
            if (measureMatchParentChildren && (matchWidth || matchHeight)) {
                mMatchParentChildren.add(child);
            }/*ww  w. jav  a  2  s . c o  m*/

            measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);

            // Measured dimensions only count against the maximum
            // dimensions if they're not MATCH_PARENT.
            int state = 0;

            if (measureMatchParentChildren && !matchWidth) {
                maxWidth = Math.max(maxWidth, child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
                state |= ViewCompat.getMeasuredWidthAndState(child) & ViewCompat.MEASURED_STATE_MASK;
            }

            if (measureMatchParentChildren && !matchHeight) {
                maxHeight = Math.max(maxHeight, child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
                state |= (ViewCompat.getMeasuredHeightAndState(child) >> ViewCompat.MEASURED_HEIGHT_STATE_SHIFT)
                        & (ViewCompat.MEASURED_STATE_MASK >> ViewCompat.MEASURED_HEIGHT_STATE_SHIFT);
            }

            childState = ViewCompat.combineMeasuredStates(childState, state);
        }
    }

    // Account for padding too.
    maxWidth += getPaddingLeft() + getPaddingRight();
    maxHeight += getPaddingTop() + getPaddingBottom();

    // 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(ViewCompat.resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
            ViewCompat.resolveSizeAndState(maxHeight, heightMeasureSpec,
                    childState << ViewCompat.MEASURED_HEIGHT_STATE_SHIFT));

    // Measure remaining MATCH_PARENT children again using real dimensions.
    final int matchCount = mMatchParentChildren.size();
    for (int i = 0; i < matchCount; i++) {
        final View child = mMatchParentChildren.get(i);
        final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();

        final int childWidthMeasureSpec;
        if (lp.width == LayoutParams.MATCH_PARENT) {
            childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
                    getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - lp.leftMargin - lp.rightMargin,
                    MeasureSpec.EXACTLY);
        } else {
            childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
                    getPaddingLeft() + getPaddingRight() + lp.leftMargin + lp.rightMargin, lp.width);
        }

        final int childHeightMeasureSpec;
        if (lp.height == LayoutParams.MATCH_PARENT) {
            childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
                    getMeasuredHeight() - getPaddingTop() - getPaddingBottom() - lp.topMargin - lp.bottomMargin,
                    MeasureSpec.EXACTLY);
        } else {
            childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
                    getPaddingTop() + getPaddingBottom() + lp.topMargin + lp.bottomMargin, lp.height);
        }

        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    }

    mMatchParentChildren.clear();
}

From source file:com.philliphsu.bottomsheetpickers.date.DayPickerViewPager.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // populate();
    // Use reflection
    callPopulate();//from w w w .  j  av  a2s .c om

    // Everything below is mostly copied from FrameLayout.
    int count = getChildCount();

    final boolean measureMatchParentChildren = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY
            || MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY;

    int maxHeight = 0;
    int maxWidth = 0;
    int childState = 0;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            measureChild(child, widthMeasureSpec, heightMeasureSpec);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            maxWidth = Math.max(maxWidth, child.getMeasuredWidth());
            maxHeight = Math.max(maxHeight, child.getMeasuredHeight());
            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 += getPaddingLeft() + getPaddingRight();
    maxHeight += getPaddingTop() + getPaddingBottom();

    // Check against our minimum height and width
    maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
    maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());

    if (Utils.checkApiLevel(Build.VERSION_CODES.M)) {
        // 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 LayoutParams lp = (LayoutParams) child.getLayoutParams();
            final int childWidthMeasureSpec;
            final int childHeightMeasureSpec;

            if (lp.width == LayoutParams.MATCH_PARENT) {
                childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
                        getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
            } else {
                childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
                        getPaddingLeft() + getPaddingRight(), lp.width);
            }

            if (lp.height == LayoutParams.MATCH_PARENT) {
                childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
                        getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY);
            } else {
                childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
                        getPaddingTop() + getPaddingBottom(), lp.height);
            }

            child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
        }
    }

    mMatchParentChildren.clear();
}

From source file:com.jun.elephant.ui.topic.details.TopicDetailsActivity.java

private void setDrawableTop(TextView textView, int resId) {
    Drawable drawable = ContextCompat.getDrawable(this, resId);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    textView.setCompoundDrawables(null, drawable, null, null);
}

From source file:com.jun.elephant.ui.topic.details.TopicDetailsActivity.java

private void setDrawableLeft(TextView textView, int resId) {
    Drawable drawable = ContextCompat.getDrawable(this, resId);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    textView.setCompoundDrawables(drawable, null, null, null);
}

From source file:com.flan.stock.fragment.FragmentQuotationHs.java

@Override
public void onStart() {
    super.onStart();

    //?ScrollView???
    /*scrollView.setOnTouchListener(new OnTouchListener() {
               /*w ww  .  j a  v a  2  s. c  o m*/
       @Override
       public boolean onTouch(View v, MotionEvent event) {
            
    if(event.getAction() == MotionEvent.ACTION_MOVE){
               
       if(event.getY()-scrollView.downY>10){
          //
          parentActivity.tabWidgetIsVisable(true);
       }else {
          //
          if(scrollView.getScrollY() - scrollView.scrollDownY > 10){
             parentActivity.tabWidgetIsVisable(false);
          }
       }
               
       System.out.println("scroll oy"+scrollView.scrollDownY+" ny="+scrollView.getScrollY());
    }
    v.performClick();
    return false;
       }
    });
    */

    zfbTitle.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (zfbIsClose) {
                Drawable drawable = getResources().getDrawable(R.drawable.label_expand);
                /// ??,??.
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                tv_zfb.setCompoundDrawables(drawable, null, null, null);
                nslv_zfb.setVisibility(View.VISIBLE);
                zfbIsClose = false;
            } else {
                Drawable drawable = getResources().getDrawable(R.drawable.label_close);
                /// ??,??.
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                tv_zfb.setCompoundDrawables(drawable, null, null, null);
                nslv_zfb.setVisibility(View.GONE);
                zfbIsClose = true;
            }
        }
    });

    TextView zfbMore = (TextView) zfbTitle.findViewById(R.id.hs_more);
    zfbMore.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, HSAStockActivity.class);
            startActivity(intent);
        }
    });

}

From source file:com.example.prox.model.DrawableLoader.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }//  w ww.j ava  2s  .  c om

    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");
        drawableMap.put(urlString, drawable);
        Log.d(this.getClass().getSimpleName(),
                "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight() + ","
                        + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                        + drawable.getMinimumWidth());
        return drawable;
    } catch (MalformedURLException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    }
}

From source file:com.wilson.android.library.DrawableManager.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }//from  ww  w .j a  v a  2s.c o  m

    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");
        drawableMap.put(urlString, drawable);
        Log.d(this.getClass().getSimpleName(),
                "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight() + ","
                        + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                        + drawable.getMinimumWidth());
        return drawable;
    } catch (MalformedURLException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (NullPointerException e) {
        Log.e(this.getClass().getSimpleName(), "Null image. Bad url?", e);
        return null;
    }
}

From source file:com.calvitium.playground.marvelcharacters.util.DrawableManager.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }/*from   w  w  w  .j  av a  2  s . c om*/

    Log.d(TAG, "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");

        if (drawable != null) {
            drawableMap.put(urlString, drawable);
            Log.d(TAG,
                    "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight()
                            + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                            + drawable.getMinimumWidth());
        } else {
            Log.w(TAG, "could not get thumbnail");
        }

        return drawable;
    } catch (MalformedURLException e) {
        Log.e(TAG, "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(TAG, "fetchDrawable failed", e);
        return null;
    }
}

From source file:com.novel.lightnovel.Utils.DrawableManager.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }//from   w ww  .ja  va2 s  .  c  o m
    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");
        if (drawable != null) {
            drawableMap.put(urlString, drawable);
            Log.d(this.getClass().getSimpleName(),
                    "got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight()
                            + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + ","
                            + drawable.getMinimumWidth());
        } else {
            Log.w(this.getClass().getSimpleName(), "could not get thumbnail");
        }
        return drawable;
    } catch (MalformedURLException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    } catch (IOException e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    }
}