본문 바로가기

APP/AndroidStudio

[Android Studio] 버튼 및 레이아웃 그림자 효과주기 Shadow Effect

반응형

[Android Studio] 버튼 및 레이아웃 그림자 효과 주기 Shadow Effect

 

 

1. shadow.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:top="0dp" android:right="1dp" android:bottom="2dp" android:left="0dp" /> <corners android:radius="5dp" /> <solid android:color="#00CCCCCC" /> </shape> </item>
    <item> <shape> <padding android:top="0dp" android:right="1dp" android:bottom="2dp" android:left= "0dp" /> <corners android:radius="5dp" /> <solid android:color="#10CCCCCC" /> </shape> </item>
    <item> <shape> <padding android:top="0dp" android:right="1dp" android:bottom="2dp" android:left="0dp" /> <corners android:radius="5dp" /> <solid android:color="#20CCCCCC" /> </shape> </item>
    <item> <shape> <padding android:top="0dp" android:right="1dp" android:bottom="2dp" android:left="0dp" /> <corners android:radius="5dp" /> <solid android:color="#30CCCCCC" /> </shape> </item>
    <item> <shape> <padding android:top="0dp" android:right="1dp" android:bottom="2dp" android:left="0dp" /> <corners android:radius="5dp" /> <solid android:color="#50CCCCCC" /> </shape> </item>
    <!-- Background -->
    <item> <shape> <solid android:color="#ffffff" /> <corners android:radius="0dp" /> </shape> </item>
</layer-list>

 

2. activity_main.xml 코드 추가

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_margin="10dp"
        android:background="@drawable/shadow">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="그림자"
            android:gravity="center"/>
</LinearLayout>

 

최종결과

 

반응형