Programmatically add ImageView and text to GridView - android

I'm display a list of items that has this same format (and I don't know how many of them):
Icon SomeText SomeText SomeText
Icon SomeText SomeText SomeText
...
I am using a GridView to display this so the list is scrollable.
I believe an ArrayAdapter would help me fill in the text fields.
But about the Icon fields, because they are .gif URLs, I am thinking about downloading the images first then put each one in an ImageView but I haven't figured out how do I programmatically do this.

There are libraries for that, most notably Picasso by guys from square, and glide used in samples from Google.
Spend two minutes with google.com and found a tutorial for your https://futurestud.io/blog/picasso-adapter-use-for-listview-gridview-etc/
But then, you are using GIF files, so I guess you should us
Ion
as it supports GIF format.
So replace picasso used in tutorial with Ion and you should have what you want.

Related

Android: Gridview performance?

on my Activity i've got on each side (on the right/on the left) a constrain Layout (100dp width). Between those gridviews i have a Gridlayout. This grid i fill with the help of an adapter. Now it contains 32*52 squares which contain a black/white image. With buttons placed on the constrain layouts i change the colour of choosen squares. But if i try this on several devices, this way is not realy performant and quite laggy. Is der a better way to do this? How? I found something on Bitmaps and canverals.. would this be better? How should i use this? Can someone recommend a tutorial? Or what other ways of achieving this exists?
Thanks a lot!
As all we know, RecyclerView enhance flexibility and also improve smoothness. So you can use RecyclerView Or RecyclerView with CardView.
And instead of using Bitmaps I would recommend you to use Glide
Library to Show Images
You can use Glide library for display image.So just add it in
build.gradle(Module App)
compile 'com.github.bumptech.glide:glide:3.7.0'
to set Images
Glide.with(context).load(image_path).into(imageView);
Note: image_path can be string, int resource, file or anything else bcoz Glide can load everything
Following are the tutorial links for RecyclerView with cardview:
link1: http://www.androidhive.info/2016/01/android-working-with-recycler-view/
link2: http://www.androidhive.info/2016/05/android-working-with-card-view-and-recycler-view/

Flow&Dynamic TextView with images inside it

I think that HTML might be a solution. But how can I achieve this:
with multiple screens sizes support?
I have found this library: FlowTextView
But it doesn't provide the way to put images inside text, like html does. And I also want to drag/resize image's inside text :D
Important to keep images on the same place on multipile devices.
So. What is the solution? Must I go ahead with custom View?
What can you recomend?

Load image from url to Recyclerview

I have an app that loads content from a database as well as images from the internet. I am using a RecyclerView along with CardView to display my content in a list form.
Each row has an image on the left side and text on the right.
The problem is that the text loads fast but the image takes time to load, so I want the image to continue loading in the background and then load into the ImageView object once loading is complete. I have no idea how to tackle this.
I use Picasso for this situation, but u can also use Glide and many more libraries. The documentation is pretty simple.
Try Picasso:http://square.github.io/picasso/
It's a one liner in onBindViewholder():
Picasso.with(context).load(url).into(viewHolder.imageView);

How to achieve following on placeholder image in ImageView Android like Pinterest?

I have used Picasso in my Android Application which has many images. Its working and looking good. I am trying to make UI more of simple and user friendly. I have placeholder for my imageviews before actual image loads. But its white color. I want to placeholder image depending on main color of image like pinterest.
Pinterest placeholder images before main image loads. Following screenshot:
And after image loads it shows proper image based on main background color shown for placeholder:
Is it possible to achieve in Picasso library provided by Square or whats the way to achieve.
Please help.
Bit late but for other readers that want to accomplish a similar thing, I'll just leave this here. I don't know how Pinterest did/does it, probably developed their own implementation. But Google updated the v7 support library with 'Palette' which is a new API which allows you to extract prominent colours from images when provided with an Image Bitmap.
Edit: Something I just realised that this probably doesn't help for placeholders since you need an image to actually get colours from! So my best guess is that Pinterest does the colour extraction from the server and includes the colour in the (presumably) JSON response that is sent to the client.
I haven't used it much myself but it works quite well from what I've seen/read. You can read up more about it at these two places:
Developer Docs
Tutorial/Explanation (Willow Tree Apps)
You can only do that by saving the prominent color from the image while saving it in your database & then retrieving it for later use.
https://pypi.org/project/extcolors/ is a very easy to use python library that extracts the colors for you given an image.
Or you could you https://github.com/woltapp/blurhash a library that'll give you this.
Both ways, you'll have to first save the BlurHash or The color as a metadata in your database, and then when the user requests the data, you'll send either of those and display them till the data is fully downloaded.

How to create custom Layout?

In my apps i want to display images and text in three ways
ListView
GridView
FullScreen
i have 500+ images and text that i parse using JSON and store into SQLite.
I know how to create ListView & GridView but problem is I don't know how to create the custom layout.
I have image but due to my low reputation i am not able to post image.
I try to explain what i need.
I need custom fullscreen layout that has 2 buttons, one on the left and other on the right and between those 2 buttons I need Imageview that display the fullscreen image.
thanks in advance
Use UniversalImageLoader library, as it has all the modes you need. It also supports caching and lazy load, which you will definitely need on 500 images.

Categories

Resources