List of usage examples for android.widget ImageView getHeight
@ViewDebug.ExportedProperty(category = "layout") public final int getHeight()
From source file:com.umeng.comm.ui.imagepicker.adapters.ImagePagerAdapter.java
/** * ?imagewrap_content,match_parent250</br> * //w w w. j a va 2s . c om * @param imageView * @return */ private Point getSize(ImageView imageView) { Point size = new Point(); if (imageView.getWidth() > 0) { size.x = imageView.getWidth(); size.y = imageView.getHeight(); } else { size.x = size.y = 250; } return size; }
From source file:com.umeng.common.ui.adapters.ImagePagerAdapter.java
/** * ?imagewrap_content,match_parent250</br> * /*ww w .j a v a 2 s . c o m*/ * @param imageView * @return */ private Point getSize(ImageView imageView) { Point size = new Point(); if (imageView.getWidth() > 0) { size.x = imageView.getWidth(); size.y = imageView.getHeight(); } else { size.x = size.y = 500; } return size; }
From source file:nz.ac.otago.psyanlab.common.util.BitmapCache.java
public void loadBitmap(String path, ImageView imageView) { final BitmapPack pack = getBitmapFromMemCache(path); if (pack != null) { if (pack.sampleSize > 1 && (pack.bitmap.getWidth() < imageView.getWidth() || pack.bitmap.getHeight() < imageView.getHeight())) { // The image was sampled before for a smaller ImageView and now // needs to be re-sampled for the new ImageView. new BitmapWorkerTask(imageView).execute(prepareBitmapParams(path, imageView)); } else {// w w w . ja va2 s . c o m imageView.setImageBitmap(pack.bitmap); } } else { new BitmapWorkerTask(imageView).execute(prepareBitmapParams(path, imageView)); } }
From source file:org.que.activities.fragments.MapImageFragment.java
/** * Scales the bitmap to save memory and to show the hole image in the image view. * //w w w . j a va2s . c o m * @param imageView the image view which shows the bitmap * @param o the bitmap options which contains the bitmap informations * @param btm the bitmap which should be scaled * @return the scaled bitmap */ private Bitmap scaleImage(ImageView imageView, BitmapFactory.Options o, Bitmap btm) { int viewWidth = imageView.getWidth(); int viewHeight = imageView.getHeight(); int imgWidth = o.outWidth;//bitm.getWidth(); int imgHeight = o.outHeight;//bitm.getHeight(); float scaleX = viewWidth / (float) imgWidth; float scaleY = viewHeight / (float) imgHeight; if (btm == null) { btm = BitmapFactory.decodeResource(getResources(), imgRes); } Bitmap b2 = Bitmap.createScaledBitmap(btm, (int) (scaleX * imgWidth), (int) (scaleY * imgHeight), false); if (btm != b2) { btm.recycle(); } return b2; }
From source file:com.github.programmerr47.vkgroups.imageloading.ImageWorker.java
private void handleParams(ImageView imageView, LoadBitmapParams params) { if (params.imageHeight == 0) { params.imageHeight = imageView.getHeight(); }//w w w. j a v a 2 s . c o m if (params.imageWidth == 0) { params.imageWidth = imageView.getWidth(); } }
From source file:com.keylesspalace.tusky.activity.MainActivity.java
private void fetchUserInfo() { SharedPreferences preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE); final String domain = preferences.getString("domain", null); String id = preferences.getString("loggedInAccountId", null); String username = preferences.getString("loggedInAccountUsername", null); if (id != null && username != null) { loggedInAccountId = id;//from w ww.j a v a 2s . co m loggedInAccountUsername = username; } mastodonAPI.accountVerifyCredentials().enqueue(new Callback<Account>() { @Override public void onResponse(Call<Account> call, Response<Account> response) { if (!response.isSuccessful()) { onFetchUserInfoFailure(new Exception(response.message())); return; } Account me = response.body(); ImageView background = headerResult.getHeaderBackgroundView(); int backgroundWidth = background.getWidth(); int backgroundHeight = background.getHeight(); if (backgroundWidth == 0 || backgroundHeight == 0) { /* The header ImageView may not be layed out when the verify credentials call * returns so measure the dimensions and use those. */ background.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY); backgroundWidth = background.getMeasuredWidth(); backgroundHeight = background.getMeasuredHeight(); } Picasso.with(MainActivity.this).load(me.header).placeholder(R.drawable.account_header_missing) .resize(backgroundWidth, backgroundHeight).centerCrop().into(background); headerResult.addProfiles(new ProfileDrawerItem().withName(me.getDisplayName()) .withEmail(String.format("%s@%s", me.username, domain)).withIcon(me.avatar)); onFetchUserInfoSuccess(me.id, me.username); } @Override public void onFailure(Call<Account> call, Throwable t) { onFetchUserInfoFailure((Exception) t); } }); }
From source file:eu.liveGov.libraries.livegovtoolkit.activities_fragments.MapFragment.java
private void SetPopup(OverlayItem item) { if (item == null) { if (_popupView != null) { mOsmv.removeView(_popupView); mOsmv.setOnClickListener(null); mOsmv.setClickable(false);/*ww w . j av a2 s .c o m*/ } } else { mOsmv.setOnClickListener(outsideClick); if (_popupView == null) { _popupView = getLayoutInflater(new Bundle()).inflate(R.layout.map_itempopup, mOsmv, false); ImageButton imbClose = (ImageButton) _popupView.findViewById(R.id.imbInfoClose); imbClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mOsmv.removeView(_popupView); } }); _popupView.setOnClickListener(this); } mOsmv.removeView(_popupView); _popupView.setTag(item.getUid()); TextView tv = (TextView) _popupView.findViewById(R.id.map_popup_title); tv.setText(item.getTitle()); tv.setTag(item.getUid()); TextView dv = (TextView) _popupView.findViewById(R.id.map_popup_description); dv.setText(item.getSnippet()); dv.setTag(item.getUid()); ImageView iv = (ImageView) _popupView.findViewById(R.id.map_popup_Thumbnail); ProposalObject proposalObject = ProposalHelper.getProposalById(Integer.parseInt(item.getUid())); iv.setImageBitmap(proposalObject.get_image(iv.getWidth() / 2, iv.getHeight() / 2)); MapView.LayoutParams mapParams = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, item.getPoint(), MapView.LayoutParams.BOTTOM_CENTER, 0, 0); mOsmv.addView(_popupView, mapParams); } }
From source file:net.maa123.tatuky.MainActivity.java
private void onFetchUserInfoSuccess(Account me, String domain) { // Add the header image and avatar from the account, into the navigation drawer header. headerResult.clear();/* w w w. j a va 2 s . c o m*/ ImageView background = headerResult.getHeaderBackgroundView(); int backgroundWidth = background.getWidth(); int backgroundHeight = background.getHeight(); if (backgroundWidth == 0 || backgroundHeight == 0) { /* The header ImageView may not be layed out when the verify credentials call returns so * measure the dimensions and use those. */ background.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY); backgroundWidth = background.getMeasuredWidth(); backgroundHeight = background.getMeasuredHeight(); } background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark)); Picasso.with(MainActivity.this).load(me.header).placeholder(R.drawable.account_header_default) .resize(backgroundWidth, backgroundHeight).centerCrop().into(background); headerResult.addProfiles(new ProfileDrawerItem().withName(me.getDisplayName()) .withEmail(String.format("%s@%s", me.username, domain)).withIcon(me.avatar)); // Show follow requests in the menu, if this is a locked account. if (me.locked) { PrimaryDrawerItem followRequestsItem = new PrimaryDrawerItem().withIdentifier(6) .withName(R.string.action_view_follow_requests).withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_person_add); drawer.addItemAtPosition(followRequestsItem, 3); } // Update the current login information. loggedInAccountId = me.id; loggedInAccountUsername = me.username; getPrivatePreferences().edit().putString("loggedInAccountId", loggedInAccountId) .putString("loggedInAccountUsername", loggedInAccountUsername) .putBoolean("loggedInAccountLocked", me.locked).apply(); }
From source file:codingpractice.renard314.com.products.ui.ProductDetailFragment.java
private void startLoadingImage(final ImageView imageView, final String name, final boolean extractColor) { imageView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") @SuppressWarnings("deprecation") @Override//w ww .j av a 2 s . com public void onGlobalLayout() { final int width = imageView.getWidth(); final int height = imageView.getHeight(); loadImage(width, height, imageView, name, extractColor); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imageView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { imageView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); }
From source file:com.landenlabs.all_UiDemo.frag.ImageScalesFrag.java
private Bitmap fillUpperLeft(final Drawable drawable, ImageView imageView, Bitmap prevBm) { // Compute matrix to fill viewer with drawable starting with upper left // Stretching till 2nd edge is crossed (filling screen) with correct aspect ratio. Matrix m = new Matrix(); m.reset();// www .j a va2s . co m int imgWidth = drawable.getIntrinsicWidth(); int imgHeight = drawable.getIntrinsicHeight(); int viewWidth = imageView.getWidth(); int viewHeight = imageView.getHeight(); float xScale = (float) viewWidth / imgWidth; float yScale = (float) viewHeight / imgHeight; float maxScale = Math.max(xScale, yScale); m.postScale(maxScale, maxScale); imageView.setScaleType(ImageView.ScaleType.MATRIX); imageView.setImageMatrix(m); imageView.setImageDrawable(drawable); return prevBm; }