For developer/Android

(Android)그라디언트 ,finger_drawable

프린이0218 2020. 5. 15. 10:48

RES->drawable->마오->new->drawable resource file 생성

 

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#4CAF50"
        android:centerColor="#CD1F1F"
        android:endColor="#1E37C6"
        android:angle="90"
        android:centerY="0.5"/>

    <corners android:radius="10dp"></corners>
</shape>

-angle-

0도: 좌에서 우로

90도 : 아래에서 위로

180도: 우에서 좌로

270도: 위에서 아래로

 

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
        android:drawable="@drawable/finger_pressed"/>

    <item android:drawable="@drawable/finger"/>

</selector



<item android:state_pressed="true"
android:drawable="@drawable/finger_pressed"/>

 

눌렀을 때 pressed 이미지 출력
<item android:drawable="@drawable/finger"/>

아닐 때 그냥 finger 출력

 

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <size android:width="200dp" android:height="120dp"/>
    <stroke android:width="1dp" android:color="#0000ff"/>
    <solid android:color="#00ff00"/>
    <padding android:bottom="1dp"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="rectangle">
            <size android:width="200dp" android:height="100dp"/>
            <stroke android:width="1dp" android:color="#FF0157"/>
            <solid android:color="#ffffff"/>
        </shape>
    </item>

    <item android:top="2dp" android:bottom="2dp"
            android:right="2dp" android:left="2dp">

            <shape android:shape="rectangle">
                <stroke android:width="1dp" android:color="#00ff00"/>

            </shape>
    </item>

    <item android:top="4dp" android:bottom="4dp"
        android:right="4dp" android:left="4dp">

        <shape android:shape="rectangle">
            <stroke android:width="1dp" android:color="#0000ff"/>

        </shape>
    </item>

</layer-list>