[Android] 08강. 버튼 이미지 애니메이션(Image Button)
ANDROID/CONCEPT 2018. 3. 27. 01:31 |MainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 | package com.example.kbw.a8; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } | cs |
button1.xml
1 2 3 4 5 6 7 8 9 | <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/click" android:state_pressed="true"></item> <item android:drawable="@drawable/hover" android:state_hovered="true"></item> <item android:drawable="@drawable/normal" android:state_focused="true"></item> </selector> <!--1. 버튼이 press (click) 2. 마우스가 focus (hover) 3. normal--> | cs |
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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.kbw.a8.MainActivity"> <ImageButton android:id="@+id/imageButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:background="@drawable/normal" app:srcCompat="@drawable/button1" tools:layout_editor_absoluteX="157dp" tools:layout_editor_absoluteY="68dp" /> </RelativeLayout> | cs |
'ANDROID > CONCEPT' 카테고리의 다른 글
[Android] 로딩화면(Splash) (0) | 2018.03.28 |
---|---|
[Android][동빈나] 07강. 유튜브 API 연동 (0) | 2018.03.27 |
[Android] 06강. 액티비티 화면 전환 (Activity Change) (0) | 2018.03.26 |
[Android] 4강 - 네비게이션 메뉴 바 만들기 (To Make Menu) (0) | 2018.03.26 |
[Android] DJ MIXING 만들기 (0) | 2018.03.25 |