B4A Library BetterImageView

Informatix

Expert
Licensed User
This is an enhanced ImageView, closer to the standard Java ImageView, with two layers (foreground and background), a touch event, a scaletype setting (similar to gravity, but for the foreground), an alpha setting and a few functions to alter the colors.
I fixed the issue with the gravity of the B4A ImageView (since it is a property of bitmapdrawables, the setting was lost when the background was changed to another type of drawable; now, this setting is kept whatever may be the contents).
It is a custom view that you can add in the designer.

screenshot.jpg
scnsht2.jpg


v1.1:
- The background set in the designer is properly read now;
- Added five functions: AlterColors, ApplyColorFilter, ReduceColors, LoadScaledBitmap and LoadNinePatchDrawable;
- Added a new demo;
- Fixed an issue in the first demo with some screen resolutions.
 

Attachments

Last edited:

NJDude

Expert
Licensed User
Thanks, but, if I may, views like these should be part of the OFFICIAL release, I'm hoping that when Erel is done with B4J, takes care of B4A. :D
 

Informatix

Expert
Licensed User
It looks like a great library. Though I don't see why it will be better to have it as part of the core library...

The core library is packaged in every app created. The core ImageView is simple and properly handles its "simple" task to show an image.
I understand your point and have no problem with this.
My request about custom views would be to improve their integration in the designer. For example, there's no mean to set a background image for this view in the designer. The label used to pass settings to the custom view has no background set.
 

thedesolatesoul

Expert
Licensed User
It looks like a great library. Though I don't see why it will be better to have it as part of the core library...
The core library is packaged in every app created. The core ImageView is simple and properly handles its "simple" task to show an image.
I think what he means is that this library adds simple enough features that he feels should be a part of the core library. (I am not sure whether core or ImageView lib, but something packages into B4A official release)

Anyway, thanks Informatix! (sorry to hijack the thread)
 

RonC.

Member
Licensed User
Praise: Informatrix, every time I get to a thread that you've started, your libraries and code really blow me away. Knock me over with a feather. ;)

All the demos worked for me except the last...

Had an issue with BIV demo 4 on Android 4.4.2 (Motorola Moto G), even in release... Got an exception and even when I passed that exception, it didn't seem as the other images hue or saturation changed. Labels didn't show for any of the images after the first.

As always, I'm adding the disclaimer that I don't know if it's me. lol.
 

Attachments

Informatix

Expert
Licensed User
Praise: Informatrix, every time I get to a thread that you've started, your libraries and code really blow me away. Knock me over with a feather. ;)

All the demos worked for me except the last...

Had an issue with BIV demo 4 on Android 4.4.2 (Motorola Moto G), even in release... Got an exception and even when I passed that exception, it didn't seem as the other images hue or saturation changed. Labels didn't show for any of the images after the first.

As always, I'm adding the disclaimer that I don't know if it's me. lol.
I have no idea of what's happened because I run the same Android version on my Nexus 7 and all is fine. Maybe you could force the bitmap to be mutable with the MakeMutable function of my Accelerated Surface lib.
 

FernandoMassa

Member
Licensed User
thanks for the super fast response. :)
I found that the panel should appear in LongClick, was below the BetterImageView. (though in the Designer panel is underneath)
Brighttofront solved the problem.
Thank you very much.;)
 

Thraka

Member
Licensed User
All of your samples use background bitmap though, along (sometimes) with the normal bitmap. Mine keep showing a solid white background when I only use the Bitmap property.

...

Ok I figured it out. :) Since the control is added as a custom type, it gets a solid white background because it's a ColorDrawable. Setting this to transparent had no effect. I have to change it to BitmapDrawable and it works as expected. I guess when you set the BackgroundBitmap property to a bitmap, it does this automatically. So the only way to get a bitmap to show without using the backgroundbitmap is to set the Drawable type to BitmapDrawable.

Working now, thanks :)
 

Informatix

Expert
Licensed User
All of your samples use background bitmap though, along (sometimes) with the normal bitmap. Mine keep showing a solid white background when I only use the Bitmap property.
I don't know what you looked at but all my examples use a foreground (the B4A logo) and a background (a photo).

So the only way to get a bitmap to show without using the backgroundbitmap is to set the Drawable type to BitmapDrawable.
I'm not sure that I understand you. You can use a bitmap directly with BackgroundBitmap or any drawable with Background.
 

Thraka

Member
Licensed User
:) I'm saying, don't use background at all. Don't set the property. If you just drop the control on a panel, then in code set the bitmap (not backgroundbitmap) to something, it will just display a solid white area.

To get it to work this way, you must change the Drawable type to BitmapDrawable. Then whatever bitmap (not backgroundbitmap) you put on it will show.
 
Top