Android/이것저것

그라데이션 만들기

일상 속 둔치 2020. 5. 10. 14:49

토이 프로젝트를 하다가 어떻게 예쁘게 꾸미지 하다가 다른 디자인을 참고하니 그라데이션이 예뻐보였다.

 

그래서 추가하기로 했고 resourse.xml에서 shape를 사용하면 된다는 것을 알았다!

 

drawable 폴더에 main_gradient.xml를 생성하고 아래 코드를 작성하였다!

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:angle="45"
        android:type="linear"
        android:startColor="#00c073"
        android:endColor="#6bc62b"/>
</shape>

 

이후에 적용하고 싶은 곳에다가 아래의 설정으로 넣어주면 된다!

    android:background="@drawable/main_gradient"

 

 

이렇게 그라데이션을 넣어줄 수 있다!