How can I create a rounded corner of pressedDrawable that I get through the following code:
B4X:
Dim pressedDrawable As Object
Dim r As Reflector
Dim idPressed As Int
idPressed = r.GetStaticField("android.R$drawable", "list_selector_background")
r.Target = r.GetContext
r.Target = r.RunMethod("getResources")
pressedDrawable = r.RunMethod2("getDrawable", idPressed, "java.lang.int")
I tried to convert it to rounded corner color drawable by using the following code:
B4X:
Dim Rounded_pressedcolor As ColorDrawable
Rounded_pressedcolor.Initialize(pressedDrawable,40dip)
Thanks for you advice, but my purpose is to convert that drawable to a rounded corner drawable. I cannot find a way to round its corner besides using a colordrawable. However, just like you said, this colordrawable is expecting a color value! Is there any way I can do that?
What kind of veiw are you wanting to achieve? Maybe there is a better way to do this?
It looks to me like you are getting the Drawable object from a ListVeiw, is that correct? Are you wanting a ListVeiw which has rounded corners?
The drawable returned from this code is a StateListDrawable. This means that it holds a set of other drawables.
You can use the debugger to examine this object and see the types of drawables inside the StateListDrawable. If there is a color drawable inside then you might be able to get its color. Overall it is a bit complicated and also fragile as different devices use different default drawables.
What kind of veiw are you wanting to achieve? Maybe there is a better way to do this?
It looks to me like you are getting the Drawable object from a ListVeiw, is that correct? Are you wanting a ListVeiw which has rounded corners?
Yes, you are correct. I am customizing the Custom ListView. I already made the corner of each item in the list rounded, but I cannot make the corner of presseddrawable rounded at all.
If there is a color drawable inside then you might be able to get its color. Overall it is a bit complicated and also fragile as different devices use different default drawables.
Yes, you are correct. I am customizing the Custom ListView. I already made the corner of each item in the list rounded, but I cannot make the corner of presseddrawable rounded at all.
I'd like to help but I'm still not sure I understand why you are having a problem. If you are using the CustomListView then you can apply your own StateListDrawable to each item and have them however you want.
Would it be possible to provide a small sample of the list as you have it now and maybe a screenshot highlighting what you want changed? There's always a way, sometimes we just need to be a little creative