Showing picture in 'image' type control?

SarahWard

Banned
Is there a demo program anywhere that displays an image within a 'B4PPC like IMAGE control' container?

ListView shows images but not full screen.

Setting image as background distorts the picture's aspect ratio in order to fit it to the screen.

I wish to place an image (of smaller size than the screen size) on the screen without distorting its aspect ratio.

Is there any code that I can use to understand how to do this?

Sarah
 

SarahWard

Banned
You should have a look here:
FlickrViewer
ScrollView example
add imageview half manually post #5

Best regards.
Thanks for that Klaus, but the two apps you listed do not do what I asked for. They both use a multiple image displays to show small versions of several larger images. I need something very basic, a way to show a screensized image on the screen at full size, just like a B4ppc image control would do.
I am beginning to wonder if it can be done, or if Android is all about web browsing rather than applications.

I am trying to confirm my nature freeware apps can be ported to Android before I buy B4Android.

What is simple basic stuff in Basic4PPC (eg: viewing a screen-sized picture or displaying a screen of text from a .txt file) seems to be a major work-up in B4A. I wonder if it can show a screen of text or play an mp3 file? It is not encouraging.

My needs are very minor, I have images that are all screen sized, so no resizing required. I just need to know that I can show them one at a time, on the fly, in full screen, with my app buttons along the bottom of the display. This is something that I can program in B4PPC can do in minutes. I don't understand why I have been trying to do this without success for he last week or so.:sign0148:

B4A doesn't seem to have a simple image-type control or holder.

If I am having such hassle simply showing a screen-sized image I am wondering if B4A is going to be useful for porting B4PPC apps at all. It seems to be orientated toward html/webpage display only. :(
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Attached you have an example, it schould almost do what you want.
The images, from your tree program (B4PPC), are a little bit bigger than the standard screen size.
The screen is full size without title.

Best regards.

Edit: Source code in post #9
 

Attachments

  • ScreenShot.jpg
    ScreenShot.jpg
    51.4 KB · Views: 196
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
It seems to be orientated toward html/webpage display only. :(
Actually it isn't at all, although from the queries it does seem to be what a lot of people (but not me!) are interested in.

Basic4android has much the same set of controls, called views, that Basic4ppc has and they are used for the same purposes but in a slightly different way.

I think you may be having trouble adapting because I think you are emphasising the differences in your mind rather than looking for the similarities. There will be no trouble in porting your apps, all the functionality is present.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is there any code that I can use to understand how to do this?
Open the Designer. Press Tools - Connect to connect to the emulator.
Add an ImageView.
Add the required image file to the images files list.
Select this image in the ImageView Image property.
Save your layout.

In Sub Activity_Create call Activity.LoadLayout(...) to load this layout.

It seems to be orientated toward html/webpage display only.
This is completely wrong. The only place that html is used is with WebView.

viewing a screen-sized picture or displaying a screen of text from a .txt file
Loading a text file is done in a single line:
B4X:
Dim txt As String
txt = File.ReadString(File.DirAssets, "somefile.txt")
Can it be simpler???

Just add an EditText to your layout and call
EditText1.Text = txt to assign the text.

Showing a full screen image:
B4X:
Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "someimage.jpg"))
See the MediaPlayer tutorial for an example of playing MP3 files.
 
Upvote 0

SarahWard

Banned
Attached you have an example, it schould almost do what you want.
The images, from your tree program (B4PPC), are a little bit bigger than the standard screen size.
The screen is full size without title.

Best regards.
Dear Klaus
I cannot find the link to the example you very kindly posted. I could really do with this example! Would you please post it again?

Thanks
Sarah
 
Upvote 0

SarahWard

Banned
Actually it isn't at all, although from the queries it does seem to be what a lot of people (but not me!) are interested in.

Basic4android has much the same set of controls, called views, that Basic4ppc has and they are used for the same purposes but in a slightly different way.

I think you may be having trouble adapting because I think you are emphasising the differences in your mind rather than looking for the similarities. There will be no trouble in porting your apps, all the functionality is present.

I appreciate what you say, Andrew. Thanks very much. I will use the code that Erel has also posted and try again to get to grips with B4A. I am pleased your interest is in other aspects of Android because it means there will be great AG libraries that are not all about the iweb.

It has surprised me just how difficult it has been for me to adapt to B4A from B4ppc and Visual Basic. When I see what Erel and you have done here I realise how smart you guys must be. :sign0188:
 
Upvote 0
Top