Android Question Help Corner radius on panel

rscheel

Well-Known Member
Licensed User
Longtime User
Hey, any way to make a panel corner radius without losing lifted by code.

First of all, Thanks.

When using corner radius lift does not work panel.

B4X:
Panel1.Elevation = 2dip
             
Dim gd1 As GradientDrawable
Dim cols1(2) As Int
gd1.Initialize("TOP_BOTTOM", cols1)
gd1.CornerRadius = 20
Panel1.Background = gd1
cols1(0) = Colors.White
cols1(1) = Colors.White

All code:

B4X:
Sub JobDone(Job As HttpJob)
    ProgressDialogHide
    If Job.Success Then
             Dim res As String
            res = Job.GetString
            Log("Back from Job:" & Job.JobName )
            Log("Job Text: " & res)
            Dim parser As JSONParser
            parser.Initialize(res)
        Select Job.JobName
                Case "GetFirm"
                Dim ListFirmw As List
                ListFirmw = parser.NextArray 'returns a list with maps
                If ListFirmw.Size == 0 Then
                    Msgbox("No hay registros", "Alerta!")
                Else
                 
                    ScrollView1.Initialize(56dip *1)
                    Activity.AddView(ScrollView1, 0, 0, 100%x, 100%y)
                    ScrollView1.Panel.Height = 127dip * ListFirmw.Size 
                    ScrollView1.Panel.LoadLayout("b4a4lay1")

                    For i = 0 To ListFirmw.Size -1
                     
                        Dim Firmware As Map
                        Firmware = ListFirmw.Get(i)
                        Modelo = Firmware.Get("Modelo")
                        Pais = Firmware.Get("Pais")
                        'Android = Firmware.Get("Android")
                        'Changelist = Firmware.Get("Changelist")
                        Code = Firmware.Get("Code")
                        Link = Firmware.Get("Link")
                     
                        Panel1.Initialize("panel"&i)
                     
                        Panel1.Color=Colors.White ' el color que tu quieras
                        ScrollView1.Panel.AddView(Panel1,2%x,((i+1)*120dip),96%x,110dip)
                        anim.InitializeTranslate("anim", 0, 0, 0, -200dip)
                        anim.Duration = 500
                        anim.Start(Panel1)
                        Panel1.Elevation = 2dip
                        'Panel1.SetElevationAnimated(500, 2dip)
                     
                        Dim gd1 As GradientDrawable
                        Dim cols1(2) As Int
                        gd1.Initialize("TOP_BOTTOM", cols1)
                        gd1.CornerRadius = 20
                        Panel1.Background = gd1
                        cols1(0) = Colors.White
                        cols1(1) = Colors.White
                     
     
                        texto1.Initialize("etiqueta")
                        texto1.TextColor = Colors.Black ' el color que tu quieras
                        texto1.Text = Modelo
                        Panel1.AddView(texto1,10dip,(10dip),100%x,50%y)
                     
                        texto2.Initialize("etiqueta")
                        texto2.TextColor = Colors.Black ' el color que tu quieras
                        texto2.Text = Pais
                        Panel1.AddView(texto2,10dip,(40dip),100%x,50%y)
                     
                        texto3.Initialize("etiqueta")
                        texto3.TextColor = Colors.Blue ' el color que tu quieras
                        texto3.Text = Code
                        Panel1.AddView(texto3,10dip,(70dip),100%x,50%y)
                     
                        Dim Obj1 As Reflector
                        butt.Initialize("bototn")
                        butt.Text = Link '"Link to"&
                        'butt.TextColor = Colors.Transparent
                        butt.TextSize = 0
                        Obj1.Target = Obj1.CreateObject("android.text.util.Linkify")
                        Dim args(2) As Object
                        Dim types(2) As String
                        args(0) = butt
                        types(0) = "android.widget.TextView"
                        args(1) = 15
                        types(1) = "java.lang.int"
                        Obj1.RunMethod4("addLinks", args, types)
                        butt.SetBackgroundImage(LoadBitmapSample(File.DirAssets, "ic_cloud_download_black_48dp.png",20%x,50dip))
                        Panel1.AddView(butt,78%x,(10dip),50dip,40dip)
                     
                    Next
                End If
        End Select
    End If
End Sub
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Changing the background doesn't have any effect on the elevation.

You can try it with this code:
B4X:
Sub Globals
   Dim panel1 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   panel1.Initialize("")
   Activity.AddView(panel1, 10dip, 10dip, 200dip, 200dip)
   panel1.Color = Colors.Red
   panel1.Elevation = 20dip
End Sub

Sub Activity_Click
   Dim gd As GradientDrawable
   gd.Initialize("TR_BL", Array As Int(Colors.Red, Colors.Yellow))
   gd.CornerRadius = 10dip
   panel1.Background = gd
End Sub

Add this line to the manifest editor:
B4X:
SetApplicationAttribute(android:theme, "@android:style/Theme.Material.Light")

upload_2015-11-5_16-57-57.png
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
Thank @Erel.

Only replace this code:
B4X:
Dim gd1 As GradientDrawable
Dim cols1(2) As Int
gd1.Initialize("TOP_BOTTOM", cols1)
gd1.CornerRadius = 20
Panel1.Background = gd1
cols1(0) = Colors.White
cols1(1) = Colors.White

For this one and it worked perfect.
B4X:
Dim gd As GradientDrawable
gd.Initialize("TR_BL", Array As Int(Colors.White, Colors.White))
gd.CornerRadius = 4dip
Panel1.Background = gd


I ran into another problem when, broken screen, charging the panel again, you must be a problem that created the panel at runtime and the same with the ScrollView1.

Thanks again for your help.
 

Attachments

  • Screenshot_2015-11-05-12-18-50.png
    Screenshot_2015-11-05-12-18-50.png
    246.8 KB · Views: 291
Upvote 0
Top