Background를 custom 할 때 그라데이션식으로 그림자를 주는 방법
투명도를 주는 것을 활용하여 디자인 하였습니다.
색상코드 앞 두자리에 투명도를 줄 수 있습니다.
1.drawable 에 디자인 xml만들기
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1AF6F2FA" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1AF5EDFF" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1AEDE0FD" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1AE9D7FF" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1AE3CCFF" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1ADABDFD" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1AD3B3FB" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1AD0AEFB" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1ACEA8FF" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="2.5dp"
android:left="2.5dp"
android:right="2.5dp"
android:top="2.5dp" />
<corners android:radius="12dp"/>
<solid android:color="#1ACCA4FF" />
</shape>
</item>
<!-- Background -->
<item>
<shape>
<corners android:radius="12dp"/>
<solid android:color="@android:color/white" />
</shape>
</item>
</layer-list>
2. Activity_main.xml 코드
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:gravity="center">
<LinearLayout
android:layout_gravity="center"
android:layout_width="300dp"
android:layout_height="300dp"
android:background="@drawable/layoutdesign"
>
</LinearLayout>
</LinearLayout>
'프로그래밍 언어 > Java' 카테고리의 다른 글
[java] 10강 접근 제어자 (0) | 2021.11.19 |
---|---|
[Android java] bottom navigation bar icon 설정 안됨 해결 (0) | 2021.11.18 |
[java] 9강 overloading 이란? (0) | 2021.11.16 |
[java] 8강 Overriding 이란? (0) | 2021.11.13 |
[java 7강] 상속과 생성자 (2/2) (0) | 2021.11.12 |