set height of imageview as matchparent programmatically
imageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
imageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
Question is rather old, and I don’t know what was the situation with glide in those times, but now it can be easily done with listener (not as proposed in the answer chosen as correct). progressBar.setVisibility(View.VISIBLE); Glide.with(getActivity()) .load(args.getString(IMAGE_TO_SHOW)) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return … Read more
MediaStore.Images.Media.insertImage(getContentResolver(), yourBitmap, yourTitle , yourDescription); The former code will add the image at the end of the gallery. If you want to modify the date so it appears at the beginning or any other metadata, see the code below (Cortesy of S-K, samkirton): https://gist.github.com/samkirton/0242ba81d7ca00b475b9 /** * Android internals have been modified to store images in … Read more
Research a bit before as there are answers available. Anyhow, follow This Link and read it carefully to know how to use it. try this: import com.squareup.picasso.Transformation; public class CircleTransform implements Transformation { @Override public Bitmap transform(Bitmap source) { int size = Math.min(source.getWidth(), source.getHeight()); int x = (source.getWidth() – size) / 2; int y = … Read more
Random rnd = new Random(); paint.setARGB(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); or Random rnd = new Random(); int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); view.setBackgroundColor(color); Though in your case it seems that you want to create a new drawable and assign it to your view. What is actually the drawable in your case? Is it an image, … Read more
As far as I’ve been able to find (I’ve tried doing something similar myself), there’s no way to modify a single state after the StateListDrawable has already been defined. You can, however, define a NEW one through code: StateListDrawable states = new StateListDrawable(); states.addState(new int[] {android.R.attr.state_pressed}, getResources().getDrawable(R.drawable.pressed)); states.addState(new int[] {android.R.attr.state_focused}, getResources().getDrawable(R.drawable.focused)); states.addState(new int[] { }, … Read more
Ah, android:adjustViewBounds=”true” is required for maxWidth to work. Works now!
to change pro-grammatically use : imgview.setScaleType(ScaleType.FIT_XY); OR to change from xml use: android:scaleType=”fitXY”
I always use imageView.setImageDrawable(null);
That happens because you’re setting the src of the ImageView instead of the background. Use this instead: qImageView.setBackgroundResource(R.drawable.thumbs_down); Here’s a thread that talks about the differences between the two methods.