Android Studio 버튼 이미지 애니메이션

실행화면

  

코드

activity_main.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="com.example.smat_501.tutorial8.MainActivity">
 
    <ImageButton
        android:id="@+id/button1"
        android:layout_width="107dp"
        android:layout_height="83dp"
        android:layout_toRightOf="@id/button1"
        android:background="@drawable/grey_button12"
        android:focusableInTouchMode="true"
        android:padding="0dp"
        android:src="@drawable/button1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/button1" />
 
</android.support.constraint.ConstraintLayout>
 
cs

button1.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 
    <item android:drawable="@drawable/blue_button07"
        android:state_pressed="true">
 
    </item>
    <item android:drawable="@drawable/green_button07"
        android:state_focused="true">
 
    </item>
    <item android:drawable="@drawable/grey_button12">
    </item>
 
</selector>
cs



  


댓글