Gif image is not working in nexus one device - android

I am using gif image in my application. It is not working in nexus one device.
View view = getLayoutInflater().inflate(layout, null);
ImageView imageView = (ImageView view.findViewById(R.id.img_view_id);
GifAnimationDrawable big = new GifAnimationDrawable(getResources().openRawResource(R.raw.flights_loading_loader));
big.setOneShot(false);
imageView.setImageDrawable(big);
big.setVisible(true, true);
mProgressDialog.setContentView(view);

Related

Properly implement Custom Adapter to show images with Picasso

I have been writing and rewriting this adapter many times in different ways, but only thing I get is a blank screen when I launch the app.
I want to load images into a gridview using picasso and a string of urls as base data, but I'm not really going forward with it.
https://github.com/Valakias/PortFolioMovieApp
The problem is that the imageView width is 0 (check it using: Poster.getWidth();), that's why you're not seeing the images, the Custom Adapter is fine.
You can fix this, using setLayoutParams to set a width/height to the imageView as the example below:
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.gridview_item, null);
//Get screen size, and divide it by the number of columns of your grid view.
int width = getContext().getResources().getDisplayMetrics().widthPixels / 2;
((ImageView) convertView.findViewById(R.id.gridview_item_image)).setLayoutParams(new GridView.LayoutParams(width, width));
}
ImageView Poster = (ImageView) convertView.findViewById(R.id.gridview_item_image);
Picasso.with(getContext())
.load(getItem(position))
.fit()
.centerCrop()
.into(Poster);
Or a different approach using Picasso.resize
//Get screen size, and divide it by the number of columns of your grid view.
int width = getContext().getResources().getDisplayMetrics().widthPixels / 2;
ImageView Poster = (ImageView) convertView.findViewById(R.id.gridview_item_image);
Picasso.with(getContext())
.load(getItem(position))
.resize(width, width)
.centerCrop()
.into(Poster);
Instead of .centerCrop() you can use .centerInside()
Using .centerCrop()
Using '.centerInside()' (This will respect image aspect ratio).

Swaping images of two imageView not workng properly in android

I have made a demo for filmstrip in Android. I have taken 9 ImageViews in a LinearLayout, set images to them. However, I am getting an old bitmap while swapping the second time. What am I missing?
void swap(ImageView iv1, ImageView iv2) {
iv1.buildDrawingCache();
Bitmap b1 = iv1.getDrawingCache();
iv2.buildDrawingCache();
Bitmap b2 = iv2.getDrawingCache();
iv2.setImageBitmap(b1);
iv1.setImageBitmap(b2);
tempView.clear();
iv_image_1.postInvalidate();
iv_image_2.postInvalidate();
iv_image_3.postInvalidate();
iv_image_4.postInvalidate();
iv_image_5.postInvalidate();
iv_image_6.postInvalidate();
iv_image_7.postInvalidate();
iv_image_8.postInvalidate();
iv_image_9.postInvalidate();
}

Imageview not showing all image

Hello i am showing images in android app using gallery. I am having problem in displaying images. Some images are displayed some are not.
My adapter code is as follows:
ImageView iv;
LinearLayout layoutnew = new LinearLayout(getApplicationContext());
layoutnew.setOrientation(LinearLayout.VERTICAL);
if (convertView == null)
{
iv = new ImageView(ctx);
iv.setBackgroundDrawable(m_docs_ids[arg0]);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
int temp =(int) (height/1.7f);
int temp_y = (int) ((3*temp)/2.0f);
iv.setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT ));
}
else
{
iv = (ImageView) convertView;
}
TextView tv = new TextView(ctx);
// tv.setText(m_docs.get(arg0).DocPath);
tv.setTextColor(0xFFFFFFFF);
tv.setPadding(0, 15, 0, 0);
tv.setTag(arg0);
tv.setTextSize(18);
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT ));
tv.setGravity(Gravity.CENTER);
layoutnew.addView(iv);
layoutnew.addView(tv);
return layoutnew;
m_docs_id is a list of drawable type. i have debug it and found that it is getting correct entry. gallery is showing black for images which are not shown.
I found put that pictures placed in DCIM folders are not shown. all other images are shown
you initialize the imageViewlike this iv = new ImageView(ctx);
you should initilize the imageView like this iv = (ImageView) findViewById(R.id.mImageView);
Finally i got my problem solved. Issue was not in DCIM folder, issue was in size. The pictures taken from cell phone camera is very high and gallery was not getting those images. I set size in drawables of photo with mobile screen size. Now its running f9

Gallery is loading all the images but gallery should be load one image at a time

i have created a gallery for display images haveing pinchzoom with goto next and previous by touch . i were use to visit https://github.com/kilaka/ImageViewZoom library . i saw Gallery first upload all the images and then it is displaying images which is good activity. but gallery can upload max 4MB images , if images size go to greater than 4MB then it gives us Bitmap outofmemory error. i have used to bitmap.recycle() but it is recycle all the images.
do here any way, so my gallery upload images one by one from sdcard and when i will go to next or previous images by touch , my currently images memory should be delete . and next images should be uploaded in gallery memory . so my gallery can upload a number of images .
this is my code , this code is link from visit https://github.com/kilaka/ImageViewZoom :-
gallery = new GalleryTouch(this);
gallery = (GalleryTouch) findViewById(R.id.image);
gallery.setSpacing(20);
arrayAdapter = new ArrayAdapter<ImageView>(this, -1) {
#Override
public View getView(int position, View convertView, ViewGroup parent) {
bookM= position; return getItem(position);
}
};
if(!(it.isEmpty() )) {
Collections.sort(it);
for(int i=0; i<it.size();i++) {
ImageViewTouch imageView = new ImageViewTouch(imageTouch.this);
imageView.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
final Options options = new Options();
options.outHeight = (int) scaleHeight;
options.outWidth = (int) scaleWidth;
options.inScaled = true;
options.inPurgeable = true;
options.inSampleSize = 2;
String photoURL = it.get(i);
bitmap = BitmapFactory.decodeFile(photoURL,options);
imageView.setImageBitmap(bitmap);
arrayAdapter.add(imageView);
}
gallery.setAdapter(arrayAdapter);
}
Note:- in this code, "it" is a variable of List it; and list having a list of path of image from sd card like as sdcard/images/one.jpg , sdcard/images/two.jpg ........ etc.
please expert help me ,
thank you for your important time.

Android SDK - convert bitmap to resource for layout params issue

For some reason, when I create a bitmap from an image in asset, it does not display fullscreen. When I take an image from drawable, resId, the image shows fullscreen. Why is this?
//the image is not fullscreen
ImageView iv = new ImageView(getBaseContext());
iv.setImageBitmap(bitmapFileFromAssetorSD);
//this makes the image fullscreen
//iv.setBackgroundResource(resId);
iv.setLayoutParams(
new LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT
)
);
Try setting the appropriate ImageView.ScaleType
ImageView.setScaleType(ImageView.ScaleType.CENTER_CROP)

Categories

Resources