티스토리 뷰
values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<integer name="alpha_pressed">50</integer>
</resources>
<integer name="alpha_pressed">50</integer> 추가
drawable/btn_setting.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<bitmap android:alpha="@integer/alpha_pressed" android:src="@drawable/ic_setting" />
</item>
<item android:state_pressed="false" android:drawable="@drawable/ic_setting" />
</selector>

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center"
android:background="#BBBBFF"
tools:context=".MainActivity">
<ImageButton
android:id="@+id/btnSetting"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/btn_setting"/>
</LinearLayout>

MainActivity.kt
package com.jwsoft.kotlinproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
btnSetting.setOnClickListener {
Toast.makeText(applicationContext, "Setting", Toast.LENGTH_SHORT).show()
}
}
}

'Android > XML' 카테고리의 다른 글
| <EditText> 꾸미기 (0) | 2020.08.04 |
|---|---|
| <layer-list> (0) | 2020.08.04 |
| <TextView> 꾸미기 (0) | 2020.08.04 |
| <selector> + ViewPager2 + TabLayout (0) | 2020.08.04 |
| <View> (0) | 2020.08.04 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 코틀린
- ArrayList
- coroutine
- Kotlin
- 혀가 길지 않은 개발자
- Design Pattern
- James Kim
- View
- MVVM
- ViewModel
- Architecture Pattern
- Android
- java
- 안드로이드 #코틀린 #Android #Kotlin
- activity
- 자바
- TabLayout
- XML
- Livedata
- CoordinatorLayout
- handler
- DataBinding
- recyclerview
- Intent
- 안드로이드
- Vue.js #Vue.js + javascript
- fragment
- JSONArray
- JSONObject
- ViewPager2
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 27 | 28 | 29 | 30 | 31 |
글 보관함