I'm using the next code for "roundering the corner" of a Label and it works fine but in Android 10 does not work, the corner is flat
B4X:
Dim l_din_redondeocolor(2) As Int
l_din_redondeocolor(0)=Colors.Transparent
l_din_redondeocolor(1)=Colors.Transparent
Dim din_redondeo As GradientDrawable
din_redondeo.Initialize("TL_BR",l_din_redondeocolor)
din_redondeo.CornerRadius = 100dip
MyLabel.Background=din_redondeo
The Manifest is set as "<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="30"/>"
Should I change something in the Manifest?
What exactly doesn't work.
You are setting the colors to transparent therefore you will not see any effect.
Even if the corner radius is too big it works, didn't remember this.
I tested it with Android 11 and it works, I don't have a device with Android 10
Attached my test project.
As both colors are the same you could also get the same effect it with a ColorDrawable.
I was using GradientRadius instead of ColorDrawable and I did not really need it. I changed the code and it works perfect on any Android version
B4X:
Dim din_redondeo As ColorDrawable
din_redondeo.Initialize(Colors.black,100dip)
MyLabel.Background=din_redondeo
Nevertheless, I show you the bizarre case with the Old code and its behavior on Android 10 and Android any. Its kind of rare than it works different dependding of the Android version.
Looks strange.
Which image is Android 10 ?
In the left image, it seems to me that the Top position of the Label is out of the screen, because, when you define a corner radius, it is the same for all corners and the two upper ones don't have a radius.
In your example you set the corner radius to 100dip.
I am sure that the radius in your left image is less than 100dip.
For the right image I do not understand what happened.
Could you post a small project showing the problem?
In the left image, it seems to me that the Top position of the Label is out of the screen, because, when you define a corner radius, it is the same for all corners and the two upper ones don't have a radius.
I don't know why the project.zip is around 0.7Mb, so I coudln't upload it. I attached a .txt, please just copy/paste it in a new Module, you won't need any layout
These are the results:
For NOT Android 10:
For Android 10:
The red label is created with GradientDrawable
The black label is created with ColorDrawable
Dim l_din_redondeocolor(2) As Int
l_din_redondeocolor(0)=Colors.Transparent
l_din_redondeocolor(1)=Colors.Transparent
Dim din_redondeo As GradientDrawable
din_redondeo.Initialize("TL_BR",l_din_redondeocolor)
din_redondeo.CornerRadius = 100dip
l1.Initialize("l")
Activity.AddView(l1,Activity.Width/8,Activity.Height*7/20,Activity.Width*3/4,Activity.Height/20)
l1.Background=din_redondeo
l1.Color=Colors.Red
You are setting the background to transparent gradient, which is strange because with transparent you will see nothing.
I was already astonished in post #4.
BUT, then you reset the background color with l1.Color=Colors.Red, that is the problem.
Setting the background with the Color property sets the corner radii to ZERO.
The code below works also with GradientDrawable.
B4X:
Dim l_din_redondeocolor(2) As Int
l_din_redondeocolor(0)=Colors.Red
l_din_redondeocolor(1)=Colors.Red
Dim din_redondeo As GradientDrawable
din_redondeo.Initialize("TL_BR",l_din_redondeocolor)
din_redondeo.CornerRadius = 100dip
l1.Initialize("l"
Activity.AddView(l1,Activity.Width/8,Activity.Height*7/20,Activity.Width*3/4,Activity.Height/20)
l1.Background=din_redondeo
PS: This shows once more that without all the information it is often difficult or impossible to give concrete help.
Without having seen the full code, no helper would have thought that the background was reset somewhere else, because, in the code snippet, it was missing.
This is the reason why I almost always ask for a project showing the problem.
To make a Label like in post #5, no need to move the Label partly out of the screen you can set different corner radii with a JavaObject.
And you can play with it.
Attached the demo project.
Code for the top Label:
B4X:
Private cols(2) As Int
cols(0)=Colors.RGB(72, 61, 139)
cols(1)=Colors.Blue
Private gdw As GradientDrawable
gdw.Initialize("TOP_BOTTOM", cols)
Private jo As JavaObject
jo = gdw
jo.RunMethod("setCornerRadii", Array As Object(Array As Float(0, 0, 0, 0, 30dip, 30dip, 30dip, 30dip)))
lblTop.Background = gdw
I understand what you said and my mistake, but... Why it works different deppending of the Android version? I mean, if I had not would test it on an Android 10 I had not never realized I was making a mistake because on other devices works "fine".
I don't know ! I am afraid that this is another Google mystery when they change versions.
I tested your code on my tablet running Android 7 and I confirm that the behavior is different.