Android Question Result of the views is not equal

Theera

Well-Known Member
Licensed User
Longtime User
I have studied the code. the first view was added by the designer and the last view was added by coding.
the result of the views is not the same.

My target : I would like to make it smaller by coding
 

Attachments

  • IsNotEq.zip
    61.1 KB · Views: 65
Last edited:

PaulMeuris

Active Member
Licensed User
The gravity was set in the designer to "fill" so you have to do the same in the code.
B4X:
    ImageView2.Initialize("ImageView2")
    ImageView2.Gravity = Gravity.FILL
    ImageView2.Bitmap = aqrc.render
1678869680890.png
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
The gravity was set in the designer to "fill" so you have to do the same in the code.
B4X:
    ImageView2.Initialize("ImageView2")
    ImageView2.Gravity = Gravity.FILL
    ImageView2.Bitmap = aqrc.render
View attachment 140283
Could I create and resize awesomeqrcode by coding without view designed template?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

PaulMeuris

Active Member
Licensed User
Could I create and resize awesomeqrcode by coding without view designed template?
You could use a CustomListView (XUI Views library) as the only view that is in the layout (generate member from the designer).
The rest of the code you can write in subroutines as follows:
adding items to the clv:
Sub Activity_Resume
    For i = 0 To 4
        Dim contentstr As String = "000201" & i
        Dim backgrbmp As Bitmap = bm
        Dim logobmp As Bitmap = bm1
        Dim qrcode As AwesomeQRCode_1 = create_qrcode(contentstr,backgrbmp,logobmp)
        Dim pnl As Panel = set_clv_item(qrcode,150dip,150dip)
        clv.Add(pnl,contentstr)
    Next
    Activity.RemoveAllViews
    Activity.AddView(clv.AsView,0dip,0dip,clv.AsView.Width,clv.AsView.Height)
End Sub

Sub set_clv_item(qrc As AwesomeQRCode_1,ivwidth As Int, ivheight As Int) As Panel
    Dim pnl As Panel
    pnl.Initialize("")
    pnl.SetLayout(0dip,0dip,ivwidth,ivheight)
    Dim iv As ImageView
    iv.Initialize("")
    iv.SetLayout(0dip,0dip,ivwidth,ivheight)
    iv.Gravity = Gravity.FILL
    iv.Bitmap = qrc.render
    pnl.AddView(iv,0dip,0dip,ivwidth,ivheight)
    Return pnl
End Sub

Sub create_qrcode(contentstring As String,backgroundbitmap As Bitmap,logobitmap As Bitmap) As AwesomeQRCode_1
    Dim aqrc As AwesomeQRCode_1
    aqrc.Initialize("")
    aqrc.autoColor(True)
    aqrc.contents(contentstring)
    aqrc.background(backgroundbitmap)
    aqrc.dotScale(0.8)
    aqrc.logoScale(0.35)
    aqrc.logoMargin(20)
    aqrc.logoRadius(10)
    aqrc.logo(logobitmap)  'ไม่ใส่ logo  ต้องการรูป Backgroud เท่านั้น
    aqrc.binarizeThreshold(128)
    aqrc.binarize(False)
    aqrc.colorDark(Colors.Black)
    aqrc.colorLight(Colors.White)
    aqrc.margin(30)
    aqrc.roundedDots(True)
    aqrc.whiteMargin(True)
    Return aqrc
End Sub


Private Sub clv_ItemClick (Index As Int, Value As Object)
    Log(Value)        ' content from qr-code
End Sub
 
Upvote 0
Top