List of usage examples for android.widget ImageView setScaleType
public void setScaleType(ScaleType scaleType)
From source file:org.mariotaku.twidere.view.CardMediaContainer.java
public void displayMedia(@NonNull final MediaLoaderWrapper loader, @Nullable final ParcelableMedia[] mediaArray, final UserKey accountId, @Nullable final OnMediaClickListener mediaClickListener, @Nullable final MediaLoadingHandler loadingHandler, final long extraId, boolean withCredentials) { if (mediaArray == null || mMediaPreviewStyle == VALUE_MEDIA_PREVIEW_STYLE_CODE_NONE) { for (int i = 0, j = getChildCount(); i < j; i++) { final View child = getChildAt(i); child.setTag(null);// w w w . j a v a 2s .c om child.setVisibility(GONE); } return; } final View.OnClickListener clickListener = new ImageGridClickListener(mediaClickListener, accountId, extraId); for (int i = 0, j = getChildCount(), k = mediaArray.length; i < j; i++) { final View child = getChildAt(i); if (mediaClickListener != null) { child.setOnClickListener(clickListener); } final ImageView imageView = (ImageView) child.findViewById(R.id.mediaPreview); switch (mMediaPreviewStyle) { case VALUE_MEDIA_PREVIEW_STYLE_CODE_CROP: { imageView.setScaleType(ScaleType.CENTER_CROP); break; } case VALUE_MEDIA_PREVIEW_STYLE_CODE_SCALE: { imageView.setScaleType(ScaleType.FIT_CENTER); break; } } if (i < k) { final ParcelableMedia media = mediaArray[i]; final String url = TextUtils.isEmpty(media.preview_url) ? media.media_url : media.preview_url; if (ObjectUtils.notEqual(url, imageView.getTag()) || imageView.getDrawable() == null) { if (withCredentials) { loader.displayPreviewImageWithCredentials(imageView, url, accountId, loadingHandler); } else { loader.displayPreviewImage(imageView, url, loadingHandler); } } imageView.setTag(url); if (imageView instanceof MediaPreviewImageView) { ((MediaPreviewImageView) imageView) .setHasPlayIcon(ParcelableMediaUtils.hasPlayIcon(media.type)); } if (TextUtils.isEmpty(media.alt_text)) { child.setContentDescription(getContext().getString(R.string.media)); } else { child.setContentDescription(media.alt_text); } child.setTag(media); child.setVisibility(VISIBLE); } else { loader.cancelDisplayTask(imageView); imageView.setTag(null); child.setVisibility(GONE); } } }
From source file:com.userhook.view.UHMessageView.java
protected void loadMessage(Map<String, Object> params) { if (meta.getDisplayType().equals(UHMessageMeta.TYPE_IMAGE)) { if (meta.getButton1() != null && meta.getButton1().getImage() != null && meta.getButton1().getImage().getUrl() != null) { AsyncTask task = new AsyncTask<Object, Void, Drawable>() { @Override//from ww w .j av a 2 s . c o m protected Drawable doInBackground(Object... params) { Drawable drawable = null; try { URL url = new URL((String) params[0]); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); InputStream is = conn.getInputStream(); drawable = Drawable.createFromStream(is, "src"); int height = drawable.getIntrinsicHeight(); int width = drawable.getIntrinsicWidth(); drawable.setBounds(0, 0, width, height); } catch (Exception e) { Log.e(UserHook.TAG, "error download message image", e); } return drawable; } @Override protected void onPostExecute(Drawable result) { if (result != null) { // size image to fit inside the view int screenHeight = getResources().getDisplayMetrics().heightPixels; int screenWidth = getResources().getDisplayMetrics().widthPixels; int heightGutter = 40; int widthGutter = 40; int screenSpaceHeight = screenHeight - heightGutter * 2; int screenSpaceWidth = screenWidth - widthGutter * 2; float height = result.getIntrinsicHeight(); float width = result.getIntrinsicWidth(); float aspect = height / width; if (height > screenSpaceHeight) { height = screenHeight; width = height / aspect; } if (width > screenSpaceWidth) { width = screenSpaceWidth; height = width * aspect; } ImageView imageView = new ImageView(getContext()); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setImageDrawable(result); LayoutParams layoutParams = new LayoutParams((int) width, (int) height); layoutParams.addRule(CENTER_IN_PARENT); addView(imageView, layoutParams); // add click handler to image imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (meta.getButton1() != null) { clickedButton(meta.getButton1()); } } }); contentLoaded = true; if (showAfterLoad) { showDialog(); } } } }; task.execute(meta.getButton1().getImage().getUrl()); } } else if (UHMessageTemplate.getInstance().hasTemplate(meta.getDisplayType())) { String html = UHMessageTemplate.getInstance().renderTemplate(meta); loadWebViewContent(html); if (showAfterLoad) { showDialog(); } } else { UHPostAsyncTask asyncTask = new UHPostAsyncTask(params, new UHAsyncTask.UHAsyncTaskListener() { @Override public void onSuccess(String result) { if (result != null) { loadWebViewContent(result); } if (showAfterLoad) { showDialog(); } } }); asyncTask.execute(UserHook.UH_HOST_URL + UH_MESSAGE_PATH); } }
From source file:hongik.android.project.best.StoreActivity.java
public void drawPage() throws Exception { String query = "func=storereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();/*from w w w . j a v a2s .c o m*/ conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) return; final JSONObject store = jsonResult.getJSONArray("store").getJSONObject(0); JSONArray menu = null; if (!jsonResult.isNull("menu")) menu = jsonResult.getJSONArray("menu"); JSONArray review = null; if (!jsonResult.isNull("review")) review = jsonResult.getJSONArray("review"); //Draw Store Information Lat = Double.parseDouble(store.getString("LAT")); Lng = Double.parseDouble(store.getString("LNG")); sname = store.getString("SNAME"); ((TextViewPlus) findViewById(R.id.store_storename)).setText(sname); ((TextViewPlus) findViewById(R.id.store_address)).setText(store.getString("ADDR")); ImageLoader imgLoader = new ImageLoader(store.getString("IMG")); imgLoader.start(); try { imgLoader.join(); Bitmap storeImg = imgLoader.getBitmap(); ((ImageView) findViewById(R.id.store_image)).setImageBitmap(storeImg); } catch (InterruptedException e) { Toast.makeText(this, "Can not bring " + license + "store's image", Toast.LENGTH_SHORT).show(); Log.e("StoreInfo", "Can not bring " + license + "store's image"); } //Draw Menu Table if (menu != null) { TableRow motive = (TableRow) menuTable.getChildAt(1); for (int i = 0; i < menu.length(); i++) { JSONObject json = menu.getJSONObject(i); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[3]; final String[] elements = new String[2]; elements[0] = json.getString("ITEM#"); elements[1] = json.getString("PRICE"); imgLoader = new ImageLoader(json.getString("IMG")); imgLoader.start(); imgLoader.join(); ImageView img = new ImageView(this); Bitmap bitmap = imgLoader.getBitmap(); img.setImageBitmap(bitmap); img.setLayoutParams(motive.getChildAt(0).getLayoutParams()); img.setScaleType(ImageView.ScaleType.FIT_XY); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); tbRow.addView(img); for (int j = 0; j < 2; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j + 1).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } menuTable.addView(tbRow); } } menuTable.removeViewAt(1); //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); int rowCnt = 5; if (review.length() < 5) rowCnt = review.length(); for (int i = 0; i < rowCnt; i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].substring(0, 14) + "..."; for (int j = 0; j < 4; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.store_map); mapFragment.getMapAsync(this); }
From source file:ca.ualberta.cs.swapmyride.View.AddInventoryActivity.java
/** * After returning from the camera activity, get the photo information * and send it into the structure to get it ready. *///from www . j av a2s . co m @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("data"); Photo photo = new Photo(imageBitmap); ImageView newImage = new ImageView(getApplicationContext()); newImage.setImageBitmap(photo.getImage()); newImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE); newImage.setAdjustViewBounds(true); //gallery.removeAllViews(); gallery.addView(newImage); photos.add(photo); } }
From source file:org.totschnig.myexpenses.dialog.TransactionDetailFragment.java
public void fillData(Transaction o) { final FragmentActivity ctx = getActivity(); mLayout.findViewById(R.id.progress).setVisibility(View.GONE); mTransaction = o;//from w w w .j a v a2 s .com if (mTransaction == null) { TextView error = (TextView) mLayout.findViewById(R.id.error); error.setVisibility(View.VISIBLE); error.setText(R.string.transaction_deleted); return; } boolean doShowPicture = false; if (mTransaction.getPictureUri() != null) { doShowPicture = true; if (mTransaction.getPictureUri().getScheme().equals("file")) { if (!new File(mTransaction.getPictureUri().getPath()).exists()) { Toast.makeText(getActivity(), R.string.image_deleted, Toast.LENGTH_SHORT).show(); doShowPicture = false; } } } AlertDialog dlg = (AlertDialog) getDialog(); if (dlg != null) { Button btn = dlg.getButton(AlertDialog.BUTTON_POSITIVE); if (btn != null) { if (mTransaction.crStatus != Transaction.CrStatus.VOID) { btn.setEnabled(true); } else { btn.setVisibility(View.GONE); } } btn = dlg.getButton(AlertDialog.BUTTON_NEUTRAL); if (btn != null) { btn.setVisibility(doShowPicture ? View.VISIBLE : View.GONE); } } mLayout.findViewById(R.id.Table).setVisibility(View.VISIBLE); int title; boolean type = mTransaction.getAmount().getAmountMinor() > 0 ? ExpenseEdit.INCOME : ExpenseEdit.EXPENSE; if (mTransaction instanceof SplitTransaction) { mLayout.findViewById(R.id.SplitContainer).setVisibility(View.VISIBLE); //TODO: refactor duplicated code with SplitPartList title = R.string.split_transaction; View emptyView = mLayout.findViewById(R.id.empty); ListView lv = (ListView) mLayout.findViewById(R.id.list); // Create an array to specify the fields we want to display in the list String[] from = new String[] { KEY_LABEL_MAIN, KEY_AMOUNT }; // and an array of the fields we want to bind those fields to int[] to = new int[] { R.id.category, R.id.amount }; // Now create a simple cursor adapter and set it to display mAdapter = new SplitPartAdapter(ctx, R.layout.split_part_row, null, from, to, 0, mTransaction.getAmount().getCurrency()); lv.setAdapter(mAdapter); lv.setEmptyView(emptyView); LoaderManager manager = getLoaderManager(); if (manager.getLoader(SPLIT_PART_CURSOR) != null && !manager.getLoader(SPLIT_PART_CURSOR).isReset()) { manager.restartLoader(SPLIT_PART_CURSOR, null, this); } else { manager.initLoader(SPLIT_PART_CURSOR, null, this); } } else { if (mTransaction instanceof Transfer) { title = R.string.transfer; ((TextView) mLayout.findViewById(R.id.AccountLabel)).setText(R.string.transfer_from_account); ((TextView) mLayout.findViewById(R.id.CategoryLabel)).setText(R.string.transfer_to_account); } else { title = type ? R.string.income : R.string.expense; } } String amountText; String accountLabel = Account.getInstanceFromDb(mTransaction.accountId).label; if (mTransaction instanceof Transfer) { ((TextView) mLayout.findViewById(R.id.Account)).setText(type ? mTransaction.label : accountLabel); ((TextView) mLayout.findViewById(R.id.Category)).setText(type ? accountLabel : mTransaction.label); if (((Transfer) mTransaction).isSameCurrency()) { amountText = formatCurrencyAbs(mTransaction.getAmount()); } else { String self = formatCurrencyAbs(mTransaction.getAmount()); String other = formatCurrencyAbs(mTransaction.getTransferAmount()); amountText = type == ExpenseEdit.EXPENSE ? (self + " => " + other) : (other + " => " + self); } } else { ((TextView) mLayout.findViewById(R.id.Account)).setText(accountLabel); if ((mTransaction.getCatId() != null && mTransaction.getCatId() > 0)) { ((TextView) mLayout.findViewById(R.id.Category)).setText(mTransaction.label); } else { mLayout.findViewById(R.id.CategoryRow).setVisibility(View.GONE); } amountText = formatCurrencyAbs(mTransaction.getAmount()); } //noinspection SetTextI18n ((TextView) mLayout.findViewById(R.id.Date)) .setText(DateFormat.getDateInstance(DateFormat.FULL).format(mTransaction.getDate()) + " " + DateFormat.getTimeInstance(DateFormat.SHORT).format(mTransaction.getDate())); ((TextView) mLayout.findViewById(R.id.Amount)).setText(amountText); if (!mTransaction.comment.equals("")) { ((TextView) mLayout.findViewById(R.id.Comment)).setText(mTransaction.comment); } else { mLayout.findViewById(R.id.CommentRow).setVisibility(View.GONE); } if (!mTransaction.referenceNumber.equals("")) { ((TextView) mLayout.findViewById(R.id.Number)).setText(mTransaction.referenceNumber); } else { mLayout.findViewById(R.id.NumberRow).setVisibility(View.GONE); } if (!mTransaction.payee.equals("")) { ((TextView) mLayout.findViewById(R.id.Payee)).setText(mTransaction.payee); ((TextView) mLayout.findViewById(R.id.PayeeLabel)).setText(type ? R.string.payer : R.string.payee); } else { mLayout.findViewById(R.id.PayeeRow).setVisibility(View.GONE); } if (mTransaction.methodId != null) { ((TextView) mLayout.findViewById(R.id.Method)) .setText(PaymentMethod.getInstanceFromDb(mTransaction.methodId).getLabel()); } else { mLayout.findViewById(R.id.MethodRow).setVisibility(View.GONE); } if (Account.getInstanceFromDb(mTransaction.accountId).type.equals(AccountType.CASH)) { mLayout.findViewById(R.id.StatusRow).setVisibility(View.GONE); } else { TextView tv = (TextView) mLayout.findViewById(R.id.Status); tv.setBackgroundColor(mTransaction.crStatus.color); tv.setText(mTransaction.crStatus.toString()); } if (mTransaction.originTemplate == null) { mLayout.findViewById(R.id.PlannerRow).setVisibility(View.GONE); } else { ((TextView) mLayout.findViewById(R.id.Plan)) .setText(mTransaction.originTemplate.getPlan() == null ? getString(R.string.plan_event_deleted) : Plan.prettyTimeInfo(getActivity(), mTransaction.originTemplate.getPlan().rrule, mTransaction.originTemplate.getPlan().dtstart)); } dlg.setTitle(title); if (doShowPicture) { ImageView image = ((ImageView) dlg.getWindow().findViewById(android.R.id.icon)); image.setVisibility(View.VISIBLE); image.setScaleType(ImageView.ScaleType.CENTER_CROP); Picasso.with(ctx).load(mTransaction.getPictureUri()).fit().into(image); } }
From source file:com.yahala.ui.Views.StickersView.java
private void init() { setOrientation(LinearLayout.VERTICAL); loadRecents();/*from www . j a va 2 s . co m*/ setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { Color.parseColor("#FF373737"), Color.parseColor("#FF575757"), Color.parseColor("#FF666666") })); emojiPagerAdapter = new EmojiPagerAdapter(getContext(), EmojiManager.getInstance().stickersCategories); pager = new ViewPager(getContext()); pager.setAdapter(emojiPagerAdapter); FileLog.e("EmojiManager.stickersCategories", "" + EmojiManager.getInstance().stickersCategories.size()); PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(false); tabs.setMinimumWidth(OSUtilities.dp(50)); tabs.setTabPaddingLeftRight(OSUtilities.dp(10)); tabs.setIndicatorHeight(3); //tabs.setTabBackground(Color.parseColor("#FF3f9fe0")); tabs.setTabBackground(R.drawable.bar_selector_main); tabs.setIndicatorColor(Color.parseColor("#FFffffff")); tabs.setDividerColor(Color.parseColor("#ff222222")); tabs.setUnderlineHeight(2); tabs.setUnderlineColor(Color.parseColor("#ff373737")); //tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new OnClickListener() { public void onClick(View view) { if (StickersView.this.listener != null) { StickersView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); /* recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView);*/ addView(localLinearLayout, new LayoutParams(-1, OSUtilities.dpf(48.0f))); addView(pager); if (!EmojiManager.getInstance().stickersCategoriesDict.containsKey("recents") || EmojiManager.getInstance().stickersCategoriesDict.get("recents").stickers.size() == 0) { pager.setCurrentItem(1); } }
From source file:com.android.browser.GearsBaseDialog.java
/** * Utility method to update the icon.// w ww. ja v a 2 s.c om * Called on the UI thread. */ public void updateIcon() { if (mIcon == null) { return; } View view = findViewById(R.id.origin_icon); if (view != null) { ImageView imageView = (ImageView) view; imageView.setMaxHeight(MAX_ICON_SIZE); imageView.setMaxWidth(MAX_ICON_SIZE); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageBitmap(mIcon); imageView.setVisibility(View.VISIBLE); } }
From source file:com.zion.htf.ui.fragment.ArtistDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_artist_details, container, false); // Display artist name TextView artist_name_field = (TextView) view.findViewById(R.id.artist_name); artist_name_field.setText(this.artist.getName()); // Display label TextView label_field = (TextView) view.findViewById(R.id.label); String label = this.artist.getLabel(); String origin = this.artist.getOrigin(); if (0 < label.length()) label = origin + " / " + label; else/* w w w .ja v a2 s. c o m*/ label = origin; label_field.setText(label); // Display picture ImageView artist_photo_field = (ImageView) view.findViewById(R.id.artist_photo); int resId = this.artist.getPictureResourceId(); if (R.drawable.no_image == resId) artist_photo_field.setScaleType(ImageView.ScaleType.CENTER_INSIDE); artist_photo_field.setImageResource(resId); // Handle website button ImageButton website_button = (ImageButton) view.findViewById(R.id.website); this.website_url = this.artist.getWebsite(); if (0 == this.website_url.length()) this.disable(website_button); else website_button.setOnClickListener(this); // Handle facebook button ImageButton facebook_button = (ImageButton) view.findViewById(R.id.facebook); this.facebook_url = this.artist.getFacebook(); if (0 == this.facebook_url.length()) this.disable(facebook_button); else facebook_button.setOnClickListener(this); // Handle soundcloud button ImageButton soundcloud_button = (ImageButton) view.findViewById(R.id.soundcloud); this.soundcloud_url = this.artist.getSoundcloud(); if (0 == this.soundcloud_url.length()) this.disable(soundcloud_button); else soundcloud_button.setOnClickListener(this); // Display bio TextView bio_field = (TextView) view.findViewById(R.id.bio); String bio; try { bio = this.artist.getBio("fr".equals(Locale.getDefault().getLanguage()) ? "fr" : "en"); } catch (InconsistentDatabaseException e) { if (BuildConfig.DEBUG) e.printStackTrace(); // Just display an error message instead of the bio bio = this.getString(R.string.error_bio_inconsistent_database); // Report this through piwik } bio_field.setText(bio); return view; }
From source file:org.vshgap.ui.Components.PagerSlidingTabStrip.java
private void addIconTab(final int position, int resId) { ImageView tab = new ImageView(getContext()); tab.setFocusable(true);/*from www . jav a 2 s .c om*/ paintTabIcons(position); //tab.setImageResource(resId); tab.setImageDrawable(getResources().getDrawable(resId));//Plus tab.setScaleType(ImageView.ScaleType.CENTER); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); tab.setSelected(position == currentPosition); }
From source file:org.videolan.vlc.gui.video.MediaInfoFragment.java
private void updateImage() { if (getView() == null) return;//w ww . j a v a 2 s . c o m ImageView imageView = (ImageView) getView().findViewById(R.id.image); imageView.setImageBitmap(mImage); ViewGroup.LayoutParams lp = imageView.getLayoutParams(); lp.height = mImage.getHeight(); lp.width = mImage.getWidth(); imageView.setLayoutParams(lp); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); mPlayButton.setVisibility(View.VISIBLE); mLengthView.setVisibility(View.VISIBLE); }