0

I am trying to make the gradient in my activity the following way:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#c0c0c0"
        android:endColor="#ffffff"
        android:angle="270"/>
</shape>

The bottom part of the gradient should have the same color as the activity and views background. And I quickly realize that #ffffff (white) color is not actually background color in my application! I have made the screenshot and discovered that background is actually #ececec color.

So is there a way to use current system/theme/style background color in my XML files? I don't want to use hardcoded #ececec color because it can be different on other devices and/or Android versions...

Flanter
  • 3
  • 1

1 Answers1

2

You can use these different solutions:

  • Transparent color from android resource: @android:color/transparent
  • Transparent color with hex: #00000000 (the two first 00 make the opacity to transparent)

For more information about hex opacity color, you should read this post.

Community
  • 1
  • 1
Blo
  • 11,903
  • 5
  • 45
  • 99