Search code examples
javaandroidcssxmlgraphic

Android How too convert this CSS code into style.xml


Hi this syntax is new for me. I want to convert it into style in android. anybody describe this?

background-image:-moz-linear-gradient(46% -217% -90deg,rgb(1,47,88) 0%,rgb(0,72,140) 100%); 
background-image:linear-gradient(-90deg,rgb(1,47,88) 0%,rgb(0,72,140) 100%);
width:788px;
height:143px;

1) I want start colour 2) I want center Colour 3) I want End Colour 4) I want an angle

LIKE


Solution

  • Your code would be something like this

    <shape>
        <gradient
            android:angle="90"
            android:startColor="yourStartColour"
            android:endcolor="yourEndColour"
            android:type="linear" />
    </shape>
    

    This is the basic code for a selector, which you set as your background. android:background="@drawable/yourSelector"

    Edit: The start and end colour you are searching are these rgb(1,37,88) and rgb(0,72,140).

    If you translate this to hex values you should replace "yourStartColour" with "#012F58" and "yourEndColour" with "#00488C"