B4A Library RoundedImageView

Hi group.
This is a wrapper to a rounded ImageView ( and oval & circular ) that i needed for a small project.

Credits go to https://github.com/vinc3m1/RoundedImageView

Sample code :
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim rIv1, rIv2 , rIv3 As RoundedImageView
    Dim b As Bitmap
   
    Dim xImgSize As Int
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")

    b.Initialize(File.DirAssets,"bart.jpg")
   
    rIv1.Initialize("iv")
    rIv1.ImageBitmap=b
    rIv1.ScaleType=rIv1.SCALETYPE_FIT_XY
    Activity.AddView(rIv1,10%x,5%y,80%x,25%y)
   
    rIv2.Initialize("iv")
    rIv2.ImageBitmap=b
    rIv2.ScaleType=rIv2.SCALETYPE_CENTER_CROP
    rIv2.Oval=False
    rIv2.CornerRadius=30
    Activity.AddView(rIv2,10%x,33%y,80%x,25%y)
   
    rIv3.Initialize("iv")
    rIv3.ImageBitmap=b
    rIv3.ScaleType=rIv3.SCALETYPE_FIT_XY
    rIv3.Oval=True
    rIv3.CornerRadius=90
    xImgSize= 25%x * 100%y/100%x
    Dim States(3,1) As Int
    States(0,0) = 16842919    'Pressed
    States(1,0) = 16842910    'Enabled
    States(2,0) = -16842910  'Disabled
    Dim Color(3) As Int = Array As Int(Colors.blue,Colors.white,Colors.Red)
    rIv3.setBorderColors(States,Color)
    rIv3.BorderWidth=3dip
    Activity.AddView(rIv3,50%x-xImgSize/2,66%y,xImgSize,25%y)
       
End Sub   
Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub iv_Click
    Msgbox("Click","msg")
End Sub
Sub iv_LongClick
    Msgbox("Long click","msg")
End Sub

Source code is included, in case someone needs to do some changes/bugfixes.

Nelson
 

Attachments

  • shot.png
    shot.png
    76 KB · Views: 294
  • RoundedImageViewLib.zip
    14.2 KB · Views: 289
  • RoundedImageViewSource.zip
    6.8 KB · Views: 253

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Nelson,

Seria muito difícil fazer a RoundedImageView funcionar com o PICASSO LIBRARY?
http://www.b4x.com/android/forum/th...ownloading-and-caching-library.31495/#content


Veja este exemplo: (imgUser = IMAGEVIEW e rIv3 = RoundedImageView)

strFoto = "http://www.melhorfeedback360.com.br/upload/upload/U_1.png"

'**** FUNCIONA ******
Dim Picasso1 As Picasso: Picasso1.Initialize: Picasso1.LoadUrl(strFoto).IntoImageView(imgUser)

'**** NAO FUNCIONA *******
Dim Picasso1 As Picasso: Picasso1.Initialize: Picasso1.LoadUrl(strFoto).IntoImageView(rIv3)



É que criei um scrollview com uma lista e em cada linha tem uma foto do usuário e ela é carregada de acordo com o download do picasso e fica muito bom o efeito e nao carrega nada a aplicação, funciona com o ImageView, mas com o RoundImageView.

Creio que deva ser algum ajuste simples na Library nao é?


Obrigadúúúúú
 
Top