Monday, November 21, 2022

 HOW TO MAKE GRADIENT COLOR IN ANDROID STUDIO



 YOU CAN MAKE drawable resource  as gradient color and you can use it as background screen or background for dialog in your app android studio 

if you use android studio to make apps java or Kotlen


   the first step  is go to drawable directory in your project:


the second step : create new resource drawable file and name it myfirstgradient



and click save or ok


open the file that you have been created and paste those xml code into the file my_firest_gradient.xml





<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="135"
android:endColor="#B84F72"
android:startColor="#491551" />
<corners android:radius="15dp"/>

</shape>


NOW :

you can use the myfirstgradint.xml  drawable as back ground in your project also you can copy it to another projects



this example  show the steps  how to use it as background in your project


in your project go to Layout Directory and open first file your activity main. xml layout


  1. choose one of the widget for example linear layout or any widget
  2. click in the mouse on the widget 
  3. go to the right screen to the properties of the widget 
  4. filter to background 
  5. and choose myfirstgradient 
  6. click enter
  7. and see the result



 2 -







3    -




the result :



 HOW TO MAKE GRADIENT COLOR IN ANDROID STUDIO  YOU CAN MAKE drawable resource  as gradient color and you can use it as background screen or ...