List of usage examples for android.widget ImageView getHeight
@ViewDebug.ExportedProperty(category = "layout") public final int getHeight()
From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java
/** * Calculate Matrix for FIT_CENTER/*from ww w .j a va 2 s. c om*/ * * @param d - Drawable being displayed */ private void updateBaseMatrix(Drawable d) { ImageView imageView = getImageView(); if (null == imageView || null == d) { return; } final float viewWidth = imageView.getWidth(); final float viewHeight = imageView.getHeight(); final int drawableWidth = d.getIntrinsicWidth(); final int drawableHeight = d.getIntrinsicHeight(); mBaseMatrix.reset(); final float widthScale = viewWidth / drawableWidth; final float heightScale = viewHeight / drawableHeight; if (mScaleType == ScaleType.CENTER) { mBaseMatrix.postTranslate((viewWidth - drawableWidth) / 2F, (viewHeight - drawableHeight) / 2F); } else if (mScaleType == ScaleType.CENTER_CROP) { float scale = Math.max(widthScale, heightScale); mBaseMatrix.postScale(scale, scale); mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F, (viewHeight - drawableHeight * scale) / 2F); } else if (mScaleType == ScaleType.CENTER_INSIDE) { float scale = Math.min(1.0f, Math.min(widthScale, heightScale)); mBaseMatrix.postScale(scale, scale); mBaseMatrix.postTranslate((viewWidth - drawableWidth * scale) / 2F, (viewHeight - drawableHeight * scale) / 2F); } else { RectF mTempSrc = new RectF(0, 0, drawableWidth, drawableHeight); RectF mTempDst = new RectF(0, 0, viewWidth, viewHeight); switch (mScaleType) { case FIT_CENTER: mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.CENTER); break; case FIT_START: mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.START); break; case FIT_END: mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.END); break; case FIT_XY: mBaseMatrix.setRectToRect(mTempSrc, mTempDst, ScaleToFit.FILL); break; default: break; } } resetMatrix(); }
From source file:com.imaginamos.taxisya.taxista.activities.RegisterDriverActivity.java
private void setThumbnailImage(ImageView mImageView, String imagePath) { // Get the dimensions of the View int targetW = mImageView.getWidth(); int targetH = mImageView.getHeight(); // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imagePath, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetH); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true;/*w ww. j a va2s. c om*/ Bitmap bitmap = BitmapFactory.decodeFile(imagePath, bmOptions); mImageView.setImageBitmap(bitmap); }
From source file:koma.movieapp.ui.MoviesFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {/* ww w .j av a 2 s. c om*/ if (mMovieList.isEmpty() || mMovieList.get(dataIndex) == null) { return; } Movie movie = mMovieList.get(dataIndex); final String movieId = movie.id.toString(); if (movieId == null) return; final String movieTitle = movie.title; final String movieRating = movie.vote_average.toString(); final String movieBackdrop = movie.backdrop_path; System.out.println("Movie title in BindCollectionItemView: " + movieTitle); int movieColor = getResources().getColor(R.color.default_movie_color); int darkMovieColor = 0; final TextView titleView = (TextView) view.findViewById(R.id.movie_title); final View movieTargetView = view.findViewById(R.id.movie_target); if (movieColor == 0) { movieColor = mDefaultMovieColor; } darkMovieColor = UIUtils.scaleMovieColorToDefaultBG(movieColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // // colored filter on the images // photoView.setColorFilter(mNoTrackBranding // ? new PorterDuffColorFilter( // getResources().getColor(R.color.no_track_branding_session_tile_overlay), // PorterDuff.Mode.SRC_ATOP) // : UIUtils.makeSessionImageScrimColorFilter(darkMovieColor)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo_colored); } ViewCompat.setTransitionName(photoView, "photo_" + movieId); // when we load a photo, it will fade in from transparent so the // background of the container must be the session color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(darkMovieColor); } else { photoView.setBackgroundColor(darkMovieColor); } // render title //titleView.setTextColor(getResources().getColor(R.color.body_text_1_inverse)); //titleView.setTextColor(getResources().getColor(R.color.body_text_1_inverse)); //titleView.setBackgroundColor(getResources().getColor(R.color.material_blue_grey_800)); //titleView.setBackgroundColor(getResources().getColor(R.color.theme_primary)); titleView.setText(movieTitle == null ? "?" : movieTitle); //photoView.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.data_item_background_with_alpha),PorterDuff.Mode.SCREEN)); // set the images if (movieBackdrop != null) { mImageLoader.loadImage(Config.TMDB_IMAGE_BASE_URL + "w780" + movieBackdrop, photoView); } final View finalPhotoView = photoView; movieTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onMovieSelected(movieId, finalPhotoView); } }); // animate this card if (dataIndex > mMaxDataIndexAnimated) { mMaxDataIndexAnimated = dataIndex; } }
From source file:com.imaginamos.taxisya.taxista.activities.RegisterDriverActivity.java
private void setThumbnailImageStorage(ImageView mImageView, String imageString) { // Get the dimensions of the View int targetW = mImageView.getWidth(); int targetH = mImageView.getHeight(); // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; //BitmapFactory.decodeFile(imagePat, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetH); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true;/*from w w w . j a va2s. c om*/ // Bitmap bitmap = decodeBase64(imageString)); byte[] b = Base64.decode(imageString, Base64.DEFAULT); InputStream is = new ByteArrayInputStream(b); //Bitmap bitmap = BitmapFactory.decodeStream(is, bmOptions); Bitmap bitmap = BitmapFactory.decodeFile(imageString, bmOptions); mImageView.setImageBitmap(bitmap); }
From source file:com.github.lakeshire.photoview.PhotoViewAttacher.java
private int getImageViewHeight(ImageView imageView) { if (null == imageView) { return 0; }// w w w .j av a 2 s. com return imageView.getHeight() - imageView.getPaddingTop() - imageView.getPaddingBottom(); }
From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java
private int getImageViewHeight(ImageView imageView) { if (null == imageView) return 0; return imageView.getHeight() - imageView.getPaddingTop() - imageView.getPaddingBottom(); }
From source file:com.meiqia.meiqiasdk.third.photoview.PhotoViewAttacher.java
protected int getImageViewHeight(ImageView imageView) { if (null == imageView) return 0; return imageView.getHeight() - imageView.getPaddingTop() - imageView.getPaddingBottom(); }
From source file:ru.gkpromtech.exhibition.events.EventsFragment.java
private View createHeader(LayoutInflater inflater, int index) { final View v = inflater.inflate(R.layout.layout_events_baner, null); final ImageView image = (ImageView) v.findViewById(R.id.imageView); final TextView textDay = (TextView) v.findViewById(R.id.textDateDay); final TextView textMonth = (TextView) v.findViewById(R.id.textDateMonth); final SimpleDateFormat dateFormatDay = new SimpleDateFormat("dd", Locale.getDefault()); final SimpleDateFormat dateFormatMonth = new SimpleDateFormat("MMMM", Locale.getDefault()); Date day = EventReader.getInstance(getActivity()).getDay(index); textDay.setText(dateFormatDay.format(day)); textMonth.setText(dateFormatMonth.format(day)); final int resourceIds[] = { R.drawable.dayimage1, R.drawable.dayimage2, R.drawable.dayimage3, R.drawable.dayimage4 };/* ww w .j a va 2 s . co m*/ final int num = index % (resourceIds.length); new Handler().postDelayed(new Runnable() { @Override public void run() { if (getActivity() != null) { Bitmap b = decodeSampledBitmapFromResource(getResources(), resourceIds[num], image.getWidth(), image.getHeight()); image.setImageBitmap(b); } } }, 50); return v; }
From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java
private void checkMatrixBounds() { final ImageView imageView = getImageView(); if (null == imageView) { return;/*w ww . j av a 2s . c o m*/ } final RectF rect = getDisplayRect(getDisplayMatrix()); if (null == rect) { return; } final float height = rect.height(), width = rect.width(); float deltaX = 0, deltaY = 0; final int viewHeight = imageView.getHeight(); if (height <= viewHeight) { switch (mScaleType) { case FIT_START: deltaY = -rect.top; break; case FIT_END: deltaY = viewHeight - height - rect.top; break; default: deltaY = (viewHeight - height) / 2 - rect.top; break; } } else if (rect.top > 0) { deltaY = -rect.top; } else if (rect.bottom < viewHeight) { deltaY = viewHeight - rect.bottom; } final int viewWidth = imageView.getWidth(); if (width <= viewWidth) { switch (mScaleType) { case FIT_START: deltaX = -rect.left; break; case FIT_END: deltaX = viewWidth - width - rect.left; break; default: deltaX = (viewWidth - width) / 2 - rect.left; break; } mScrollEdge = EDGE_BOTH; } else if (rect.left > 0) { mScrollEdge = EDGE_LEFT; deltaX = -rect.left; } else if (rect.right < viewWidth) { deltaX = viewWidth - rect.right; mScrollEdge = EDGE_RIGHT; } else { mScrollEdge = EDGE_NONE; } // Finally actually translate the matrix mSuppMatrix.postTranslate(deltaX, deltaY); }
From source file:uk.co.senab.photoview.PhotoViewAttacher.java
private void calculateCurrentImageMatrix() { ImageView iv = getImageView(); if (iv != null) { currentImageMatrix.reset();/* w ww.ja va 2 s . c o m*/ currentImageMatrix.setScale((float) iv.getWidth() / originalBitmapSize.x, (float) iv.getHeight() / originalBitmapSize.y); } }