Sandman Expert Licensed User Longtime User May 24, 2017 #1 Hi, I have a layout that uses the Default Color for background, and I'd like to re-use it somewhere else. To do that I need to get what the Default Color is, but I can't figure out how to do it. I tried this: Code: Copy Dim test As ColorDrawable test.Initialize(0, 0) test = Activity.Background And I thought I'd be able to get the background using test.Color, or something like that. Nope. (I also tried looking at LayoutValues, but that's also a dead end.) I imagine I could get the API level from the OS and do an internal look-up in a pre-compiled list of colors and use that value, but that seems kind of weird - surely we can get the actual color somehow? (Not to mention that the user might have enabled an inverted look, which would make the internal list useless.) I should also mention that I'm not defining any colors in the manifest, it's a complete standard look here.
Hi, I have a layout that uses the Default Color for background, and I'd like to re-use it somewhere else. To do that I need to get what the Default Color is, but I can't figure out how to do it. I tried this: Code: Copy Dim test As ColorDrawable test.Initialize(0, 0) test = Activity.Background And I thought I'd be able to get the background using test.Color, or something like that. Nope. (I also tried looking at LayoutValues, but that's also a dead end.) I imagine I could get the API level from the OS and do an internal look-up in a pre-compiled list of colors and use that value, but that seems kind of weird - surely we can get the actual color somehow? (Not to mention that the user might have enabled an inverted look, which would make the internal list useless.) I should also mention that I'm not defining any colors in the manifest, it's a complete standard look here.
Erel B4X founder Staff member Licensed User Longtime User May 25, 2017 #2 There is no simple way to get the default colors. In fact in most cases the background is not a simple color. It is a more complex drawable. The designer doesn't set anything in order to keep the default colors. Upvote 0
There is no simple way to get the default colors. In fact in most cases the background is not a simple color. It is a more complex drawable. The designer doesn't set anything in order to keep the default colors.