Android Question Large Image display

Ajay Kakar

Member
Licensed User
Longtime User
Hi, I have a JPG file which is 1700 pixels by 640 pixels. I need to display this picture in my App. It is a fixed image and will not change and hence I have included it in my project. I created an Imageview and set it to be 1700 by 640 width and height. My screen size on the phone is much smaller. Only about 400 x 320. When i compile and run this code i get to see only part of the JPG file. If i make the Imageview small to fit into my screen, the JPG file is seen but it gets scaled down and i cannot see any detail. Any way in which i can have the full resolution image which can be scrolled horizontally as well as vertically ?

Ajay
 

klaus

Expert
Licensed User
Longtime User
Try this code:
B4X:
Sub Globals
    Dim scvImage As ScrollView2D
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim w = 2304 As Int
    Dim h = 1530 As Int
    scvImage.Initialize(w, h, "scvImage")
    Activity.AddView(scvImage, 0, 0, 100%x, 100%y)
   
    Dim bdw As BitmapDrawable
    bdw.Initialize(LoadBitmap(File.DirAssets, "rhonevalley1.png"))
    scvImage.Panel.Background = bdw
End Sub
Unfortunately I can't post the image, too big.
You need to adapt the parameters.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…