List of usage examples for android.graphics.drawable Drawable getMinimumHeight
public int getMinimumHeight()
From source file:com.aldogomez.bluebird.DrawableManager.java
public Drawable fetchDrawable(String urlString) { if (drawableMap.containsKey(urlString)) { return drawableMap.get(urlString); }/*from w ww . ja v a2s . 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; } }
From source file:com.justwayward.reader.ui.activity.BookDetailActivity.java
private void initCollection(boolean coll) { if (coll) {/*from w ww . j a v a 2s .co m*/ mBtnJoinCollection.setText(R.string.book_detail_join_collection); Drawable drawable = ContextCompat.getDrawable(this, R.drawable.book_detail_info_add_img); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); mBtnJoinCollection.setBackgroundDrawable( ContextCompat.getDrawable(this, R.drawable.shape_common_btn_solid_normal)); mBtnJoinCollection.setCompoundDrawables(drawable, null, null, null); mBtnJoinCollection.postInvalidate(); isJoinedCollections = false; } else { mBtnJoinCollection.setText(R.string.book_detail_remove_collection); Drawable drawable = ContextCompat.getDrawable(this, R.drawable.book_detail_info_del_img); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); mBtnJoinCollection .setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.btn_join_collection_pressed)); mBtnJoinCollection.setCompoundDrawables(drawable, null, null, null); mBtnJoinCollection.postInvalidate(); isJoinedCollections = true; } }
From source file:net.sarangnamu.android.DrawableManager.java
public Drawable fetchDrawable(String urlString) { if (drawableMap.containsKey(urlString)) { return drawableMap.get(urlString); }//w w w . j a v a 2 s . c o m Log.d(this.getClass().getSimpleName(), "image url:" + urlString); try { InputStream is = fetch(urlString); Drawable drawable = null; 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()); } 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.example.administrator.mengbaofushiji.extras.SlidingTabLayout.java
private void populateTabStrip() { removeOldSelection(); // add those two lines oldSelection = null;/*w w w.ja v a 2s . c o m*/ final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null; if (mTabViewLayoutId != 0) { tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); if (mTabViewTextViewImgs != null && mTabViewTextViewImgs.length > 0) { Drawable drawable = getResources().getDrawable(mTabViewTextViewImgs[i]); /// ??,??. drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); tabTitleView.setCompoundDrawables(drawable, null, null, null); } tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:com.common.widget.pageindicator.C_TabPageIndicator.java
/** * Icon? /*from w ww . j ava 2 s . co m*/ * * @param view * @param iconResId */ private void setTabIcon(TextView view, int iconResId) { Drawable drawable = context.getResources().getDrawable(iconResId); int h = drawable.getIntrinsicHeight(); // int hs = drawable.getMinimumHeight(); // // int crop = h - hs; // ? int crop = h / 5; Rect cRect = new Rect(crop, crop, h - crop, h - crop);// ? // drawable.setBounds(crop, crop, h - crop, h - crop); // // view.setCompoundDrawablesWithIntrinsicBounds(0, drawable, 0, 0); // view.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, view.setCompoundDrawables(null, drawable, null, null); }
From source file:com.kaku.weac.activities.MainActivity.java
/** * Tab//from ww w . j a v a 2 s. co m * * @param iconId Tab * @param textView Tab * @param color Tab */ private void setTextView(int iconId, TextView textView, int color) { @SuppressWarnings("deprecation") Drawable drawable = getResources().getDrawable(iconId); if (drawable != null) { drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); // textView.setCompoundDrawables(null, drawable, null, null); } // textView.setTextColor(color); }
From source file:com.neudesic.mobile.pulse.ui.drawable.DrawableManager.java
public synchronized Drawable fetchDrawable(String urlString) { if (drawableMap.containsKey(urlString)) { Log.d(getClass().getSimpleName(), "loading image from localcache"); return drawableMap.get(urlString); }/*from w ww .j a 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 (drawableMap.size() > MAX_CACHE_SIZE) { drawableMap.clear(); } 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.lepin.activity.MyLoveCarActivity.java
/** * ???/* w ww.j a va 2s .c o m*/ */ public void setVisible(boolean b) { if (b == true) { mlTitleEdit.setVisibility(View.GONE); Drawable drawable = getResources().getDrawable(R.drawable.arrow); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); mlType.setCompoundDrawables(null, null, drawable, null); mlSave.setVisibility(View.VISIBLE); mlEditShow.setVisibility(View.VISIBLE); mlSafeLayout.setVisibility(View.GONE); } else { mlTitleEdit.setVisibility(View.VISIBLE); mlType.setCompoundDrawables(null, null, null, null); mlSave.setVisibility(View.INVISIBLE); mlEditShow.setVisibility(View.GONE); mlSafeLayout.setVisibility(View.VISIBLE); } }
From source file:com.cm.beer.util.DrawableManager.java
/** * // w w w. jav a 2s. c o m * @param urlString * @return */ public Drawable fetchDrawable(String urlString) { if (mDrawableCache.containsKey(urlString)) { if (Logger.isLogEnabled()) Logger.log("Returning Drawable from Cache:" + urlString); SoftReference<Drawable> softReference = mDrawableCache.get(urlString); if ((softReference == null) || (softReference.get() == null)) { mDrawableCache.remove(urlString); if (Logger.isLogEnabled()) Logger.log("fetchDrawable():Soft Reference has been Garbage Collected:" + urlString); } else { return softReference.get(); } } if (Logger.isLogEnabled()) Logger.log("image url:" + urlString); try { // prevents multithreaded fetches for the same image mLockCache.put(urlString, urlString); if (Logger.isLogEnabled()) Logger.log("Begin Downloading:" + urlString); InputStream is = fetch(urlString); if (Logger.isLogEnabled()) Logger.log("End Downloading:" + urlString); Drawable drawable = Drawable.createFromStream(is, "src"); mDrawableCache.put(urlString, new SoftReference<Drawable>(drawable)); mLockCache.remove(urlString); if (Logger.isLogEnabled()) Logger.log("got a thumbnail drawable: " + drawable.getBounds() + ", " + drawable.getIntrinsicHeight() + "," + drawable.getIntrinsicWidth() + ", " + drawable.getMinimumHeight() + "," + drawable.getMinimumWidth()); return drawable; } catch (Throwable e) { Log.e(this.getClass().getName(), "fetchDrawable failed", e); return null; } }
From source file:com.appeaser.sublimepickerlibrary.datepicker.DayPickerViewPager.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { //populate(); // Use reflection callPopulate();//from www . j a va2 s .co m // 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 if (SUtils.isApi_23_OrHigher()) { 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(); }