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:com.insthub.ecmobile.component.PagerSlidingTabStrip.java

/** add one text tab */
private void addTextTab(final int position, String title, int res) {
    TextView tab = new TextView(getContext());
    tab.setText(title);/*from   ww  w.j  a  v a  2s . c  o  m*/
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    Drawable drawable = getResources().getDrawable(res);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    tab.setCompoundDrawables(drawable, null, null, null);
    addTab(position, tab);
}

From source file:com.geekandroid.sdk.base.BaseFragment.java

public void setDrawablePosition(TextView textView, int left, int top, int right, int bottom) {
    Drawable drawableTop = null;
    Drawable drawableLeft = null;/* w w  w  . ja  va2 s. c  o  m*/
    Drawable drawableRight = null;
    Drawable drawableBottom = null;

    if (top != 0) {
        drawableTop = getResources().getDrawable(top);
    }
    if (left != 0) {
        drawableLeft = getResources().getDrawable(left);
    }
    if (right != 0) {
        drawableRight = getResources().getDrawable(right);
    }
    if (bottom != 0) {
        drawableBottom = getResources().getDrawable(bottom);
    }
    /// ??,??.
    if (drawableTop != null) {
        drawableTop.setBounds(0, 0, drawableTop.getMinimumWidth(), drawableTop.getMinimumHeight());
    }

    if (drawableLeft != null) {
        int result = convertDp(60);
        drawableLeft.setBounds(0, 0, result, result);
        //            drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
    }
    if (drawableRight != null) {
        int result = convertDp(50);
        drawableRight.setBounds(0, 0, result, result);
        //            drawableRight.setBounds(0, 0, drawableRight.getMinimumWidth(), drawableRight.getMinimumHeight());
    }
    if (drawableBottom != null) {
        drawableBottom.setBounds(0, 0, drawableBottom.getMinimumWidth(), drawableBottom.getMinimumHeight());
    }
    int result = convertDp(10);
    textView.setCompoundDrawablePadding(result);
    textView.setCompoundDrawables(drawableLeft, drawableTop, drawableRight, drawableBottom);
}

From source file:com.example.ysh.myapplication.view.readview.TocListAdapter.java

@Override
public void convert(EasyLVHolder holder, int position, BookMixAToc.mixToc.Chapters chapters) {
    TextView tvTocItem = holder.getView(R.id.tvTocItem);
    tvTocItem.setText(chapters.title);//from  w w  w  . j  a v  a2  s.c  o  m
    Drawable drawable;
    if (currentChapter == position + 1) {
        tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_red));
        drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_activated);
    } else if (isEpub || FileUtils.getChapterFile(bookId, position + 1).length() > 10) {
        tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_black));
        drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_download);
    } else {
        tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_black));
        drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_normal);
    }
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    tvTocItem.setCompoundDrawables(drawable, null, null, null);
}

From source file:com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView.java

private void onMeasureCompat(int widthMeasureSpec, int heightMeasureSpec) {
    int count = Math.min(1, getChildCount());

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

    View matchParentChildren = null;

    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) {
            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 |= ViewCompat.getMeasuredState(child);

            if (measureMatchParentChildren) {
                if (lp.width == LayoutParams.MATCH_PARENT || lp.height == LayoutParams.MATCH_PARENT) {
                    matchParentChildren = child;
                }//from   ww w  . j  a va 2s  .  com
            }
        }
    }

    final int paddingH = getPaddingLeft() + getPaddingRight();
    final int paddingV = getPaddingTop() + getPaddingBottom();

    maxWidth += paddingH;
    maxHeight += paddingV;

    maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
    maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());

    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));

    if (matchParentChildren != null) {
        final View child = matchParentChildren;

        final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
        int childWidthMeasureSpec;
        int childHeightMeasureSpec;

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

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

        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    }
}

From source file:com.labs.okey.commonride.utils.DrawableManager.java

public Drawable fetchDrawable(String urlString) {
    if (drawableMap.containsKey(urlString)) {
        return drawableMap.get(urlString);
    }/*  ww  w . ja va  2  s  .  c o  m*/

    Log.d(this.getClass().getSimpleName(), "image url:" + urlString);
    try {
        InputStream is = fetch(urlString);
        Drawable drawable = Drawable.createFromStream(is, "src");
        if (isRounded) {
            drawable = RoundedDrawable.fromDrawable(drawable);
            if (drawable instanceof RoundedDrawable) {
                ((RoundedDrawable) drawable).setCornerRadius(cornerRadius).setBorderColor(borderColor)
                        .setBorderWidth(4).setOval(true);
            }
        }

        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;
    } catch (Exception e) {
        Log.e(this.getClass().getSimpleName(), "fetchDrawable failed", e);
        return null;
    }
}

From source file:cn.longchou.wholesale.activity.VehicleDetailActivity.java

private void setAttention() {
     isAttention = cars.isFollow;/*w w  w  . j a v  a 2s . c  o m*/

     if (!isAttention) {
         mAttention.setText("");
         Drawable drawable = getResources().getDrawable(R.drawable.car_detail_attention_no);
         drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
         mAttention.setCompoundDrawables(null, drawable, null, null);
     } else {
         mAttention.setText("?");
         Drawable drawable = getResources().getDrawable(R.drawable.car_detail_attention);
         drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
         mAttention.setCompoundDrawables(null, drawable, null, null);
     }

 }

From source file:cn.longchou.wholesale.activity.VehicleDetailActivity.java

private void showAttention() {
     //,?//w w w.ja v  a2 s  .c  o  m
     if (isAttention) {
         isAttention = false;
         mAttention.setText("");
         Drawable drawable = getResources().getDrawable(R.drawable.car_detail_attention_no);
         drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
         mAttention.setCompoundDrawables(null, drawable, null, null);

         //?
         deleteAttention();

     } //
     else {
         isAttention = true;
         mAttention.setText("?");
         Drawable drawable = getResources().getDrawable(R.drawable.car_detail_attention);
         drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
         mAttention.setCompoundDrawables(null, drawable, null, null);

         //
         addAttention();
     }
 }

From source file:com.am.pagergradienttab.view.PagerGradientTabStrip.java

/**
 * /*from w  w w. j  a v a  2  s  . c  o m*/
 * 
 * @param canvas
 */
private void drawTag(Canvas canvas) {
    // TODO
    if (mTagAdapter != null) {
        canvas.save();
        float canvasOffset = 0;
        int x = getPaddingLeft();
        int y = getPaddingTop();
        float textTop = 0;
        mTextPaint.setColor(Color.WHITE);
        mTextPaint.setTextAlign(Align.LEFT);
        for (int position = 0; position < tabs.size(); position++) {
            canvas.translate(canvasOffset, 0);
            canvasOffset = itemWidth + intervalWidth;
            canvas.save();
            if (mTagAdapter.isEnable(position)) {
                int textWidth;
                int textHeight;
                mTextPaint.setTextSize(mTagAdapter.getTextSize(position));
                String tag = mTagAdapter.getTag(position) == null ? "" : mTagAdapter.getTag(position);
                textWidth = (int) Math.ceil(mTextPaint.measureText(tag));
                FontMetrics fontMetrics = mTextPaint.getFontMetrics();
                textHeight = (int) Math.ceil(fontMetrics.descent - fontMetrics.ascent);
                textTop = textHeight - (-fontMetrics.ascent - fontMetrics.descent
                        + (fontMetrics.bottom - fontMetrics.descent) * density);
                textHeight += textTop;
                if ("".equals(tag)) {
                    textHeight = 0;
                }
                final Drawable drawable = mTagAdapter.getBackground(position);
                int drawableWidth = drawable == null ? 0 : drawable.getMinimumWidth();
                int drawableHeight = drawable == null ? 0 : drawable.getMinimumHeight();
                float offsetX = Math.max(textWidth + mTagAdapter.getPaddingLeft(position)
                        + mTagAdapter.getPaddingRight(position), drawableWidth);
                float offsetTextX = (offsetX - (textWidth + mTagAdapter.getPaddingLeft(position)
                        + mTagAdapter.getPaddingRight(position))) * 0.5f;
                float offsetY = Math.max(textHeight + mTagAdapter.getPaddingBottom(position)
                        + mTagAdapter.getPaddingTop(position), drawableHeight);
                float offsetTextY = (offsetY - (textHeight + mTagAdapter.getPaddingBottom(position)
                        + mTagAdapter.getPaddingTop(position))) * 0.5f;

                mTextPaint.setTextSize(showTextScale ? textSize * (1 + magnification) : textSize);
                float myTextWidth = mTextPaint.measureText(tabs.get(position));
                TagAlign ta = mTagAdapter.getTagAlign(position);
                switch (ta) {
                default:
                case LEFTTOP:
                    canvas.translate(mTagAdapter.getMarginLeft(position), mTagAdapter.getMarginTop(position));
                    break;
                case LEFTCENTER:
                    canvas.translate(mTagAdapter.getMarginLeft(position),
                            (getHeight() - underLineHeight - offsetY) / 2);
                    break;
                case LEFTBOTTOM:
                    canvas.translate(mTagAdapter.getMarginLeft(position),
                            getHeight() - offsetY - underLineHeight - mTagAdapter.getMarginBottom(position));
                    break;
                case RIGHTTOP:
                    canvas.translate(itemWidth - offsetX - mTagAdapter.getMarginRight(position),
                            mTagAdapter.getMarginTop(position));
                    break;
                case RIGHTCENTER:
                    canvas.translate(itemWidth - offsetX - mTagAdapter.getMarginRight(position),
                            (getHeight() - underLineHeight - offsetY) / 2);
                    break;
                case RIGHTBOTTOM:
                    canvas.translate(itemWidth - offsetX - mTagAdapter.getMarginRight(position),
                            getHeight() - offsetY - underLineHeight - mTagAdapter.getMarginBottom(position));
                    break;
                case LEFTTOPTEXT:
                    canvas.translate(
                            (itemWidth - myTextWidth) / 2 - offsetX - mTagAdapter.getMarginRight(position),
                            mTagAdapter.getMarginTop(position));
                    break;
                case LEFTCENTERTEXT:
                    canvas.translate(
                            (itemWidth - myTextWidth) / 2 - offsetX - mTagAdapter.getMarginRight(position),
                            (getHeight() - underLineHeight - offsetY) / 2);
                    break;
                case LEFTBOTTOMTEXT:
                    canvas.translate(
                            (itemWidth - myTextWidth) / 2 - offsetX - mTagAdapter.getMarginRight(position),
                            getHeight() - offsetY - underLineHeight - mTagAdapter.getMarginBottom(position));
                    break;
                case RIGHTTOPTEXT:
                    canvas.translate((itemWidth + myTextWidth) / 2 + mTagAdapter.getMarginLeft(position),
                            mTagAdapter.getMarginTop(position));
                    break;
                case RIGHTCENTERTEXT:
                    canvas.translate((itemWidth + myTextWidth) / 2 + mTagAdapter.getMarginLeft(position),
                            (getHeight() - underLineHeight - offsetY) / 2);
                    break;

                case RIGHTBOTTOMTEXT:
                    canvas.translate((itemWidth + myTextWidth) / 2 + mTagAdapter.getMarginLeft(position),
                            getHeight() - offsetY - underLineHeight - mTagAdapter.getMarginBottom(position));
                    break;

                }
                mTextPaint.setTextSize(mTagAdapter.getTextSize(position));
                if (drawable != null) {
                    drawable.setBounds(x, y, (int) (x + offsetX), (int) (y + offsetY));
                    drawable.draw(canvas);
                }
                canvas.drawText(tag, x + offsetTextX + mTagAdapter.getPaddingLeft(position),
                        y + offsetY - textTop - offsetTextY - mTagAdapter.getPaddingTop(position), mTextPaint);
            }
            canvas.restore();
        }
        canvas.restore();
    }
}

From source file:com.zhenlaidian.ui.InputCarNumberActivity.java

private void initPopWindow(final ArrayList<CarTypeItem> car_type) {

    View cartypeView = getLayoutInflater().inflate(R.layout.cartype_layout, null, false);
    pow = new PopupWindow(cartypeView, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT, true);
    // ??BackPopupWindow
    pow.setOutsideTouchable(true);/*  w w  w  .jav a  2s .c o  m*/
    pow.setBackgroundDrawable(new BitmapDrawable());
    cartypeView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (pow != null && pow.isShowing()) {
                pow.dismiss();
                pow = null;
            }
            return false;
        }
    });
    pow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            Drawable d = getResources().getDrawable(R.drawable.set_collect_on);
            d.setBounds(0, 0, d.getMinimumWidth(), d.getMinimumHeight()); //
            cartype.setCompoundDrawables(null, null, d, null);
        }
    });
    listtype = ((ListView) cartypeView.findViewById(R.id.cartype_lv_popview));

    if (car_type.size() > 9) {
        ViewGroup.LayoutParams params = listtype.getLayoutParams();
        params.height = CommontUtils.getScreenWidth(this);
        listtype.setLayoutParams(params);
    }
    cartypeAdapter = new CartypeAdapter(car_type, context);
    listtype.setAdapter(cartypeAdapter);
    listtype.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            cartypecode = car_type.get(position).getId();
            cartype.setText(car_type.get(position).getName());
            pow.dismiss();
        }
    });
}

From source file:com.fullteem.yueba.app.ui.MainActivity.java

@Override
public void initData() {
    LogUtil.LogDebug("?", "Fragment:" + System.currentTimeMillis(), null);
    mListener = new MyListener();
    // for fragent
    mFragments = new ArrayList<Fragment>(PAGE_TOATAL);
    mFragments.add(NearbyMainFragment.getInstance());
    mFragments.add(MessageMainFragment.getInstance());
    mFragments.add(DiscoverMainFragment.getInstance());
    mFragments.add(PersonalMainFragment.getInstance());

    for (int i = 0; i < mFragments.size(); i++) {
        getSupportFragmentManager().beginTransaction().add(R.id.ll_fragmentcontainer, mFragments.get(i))
                .commit();/* w  w  w.j  a  va2 s . c  o  m*/
    }
    ((NearbyMainFragment) mFragments.get(0)).onLuckyMeet();

    // for show image
    int[] imgId = { R.drawable.img_main_nearby, R.drawable.img_main_message, R.drawable.img_main_discover,
            R.drawable.img_main_personal, R.drawable.img_main_nearby_selected,
            R.drawable.img_main_message_selected, R.drawable.img_main_discover_selected,
            R.drawable.img_main_personal_selected };
    mImgUnSelected = new ArrayList<Drawable>(PAGE_TOATAL);
    for (int i = 0; i < PAGE_TOATAL; i++) {
        Drawable drawable = getResources().getDrawable(imgId[i]);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        mImgUnSelected.add(drawable);
    }
    mImgSelected = new ArrayList<Drawable>(PAGE_TOATAL);
    for (int i = 4; i < imgId.length; i++) {
        Drawable drawable = getResources().getDrawable(imgId[i]);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        mImgSelected.add(drawable);
    }

    // ??
    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);
    // ?BroadcastReceiver
    msgReceiver = new NewYBMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    intentFilter.setPriority(3);
    registerReceiver(msgReceiver, intentFilter);
    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(3);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ??BroadcastReceiver
    IntentFilter cmdMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getCmdMessageBroadcastAction());
    cmdMessageIntentFilter.setPriority(3);
    registerReceiver(cmdMessageReceiver, cmdMessageIntentFilter);

    // setContactListener???
    EMContactManager.getInstance().setContactListener(new MyContactListener());
    // ??listener
    EMChatManager.getInstance().addConnectionListener(new MyConnectionListener());
    // ?listener
    EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
    // sdkUI ??receiverlistener, ??broadcast
    EMChat.getInstance().setAppInited();
    LogUtil.LogDebug("?", "MainActivity ??:" + System.currentTimeMillis(), null);
}