# Call Button Xml : ic_baseline_call_24.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20.01,15.38c-1.23,0 -2.42,-0.2 -3.53,-0.56 -0.35,-0.12 -0.74,-0.03 -1.01,0.24l-1.57,1.97c-2.83,-1.35 -5.48,-3.9 -6.89,-6.83l1.95,-1.66c0.27,-0.28 0.35,-0.67 0.24,-1.02 -0.37,-1.11 -0.56,-2.3 -0.56,-3.53 0,-0.54 -0.45,-0.99 -0.99,-0.99H4.19C3.65,3 3,3.24 3,3.99 3,13.28 10.73,21 20.01,21c0.71,0 0.99,-0.63 0.99,-1.18v-3.45c0,-0.54 -0.45,-0.99 -0.99,-0.99z"/>
</vector>
# Button layout: activity_main.xml
<...layout...>
...
<ImageButton
android:id="@+id/btn_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_call_24"
/>
...
</...layout...>
# Button Action: MainActivity.kt
...
var btnCall: ImageButton = view.findViewById(R.id.btn_call)
var phoneNum: String = "tel:"
btnCall.setOnClickListener {
phoneNum += "01012345678"
var intent = Intent(Intent.ACTION_DIAL)
intent.data = Uri.parse(phoneNum)
startActivity(intent)
//초기화
phoneNum = "tel:"
}
...
'LANGUAGE > Kotlin' 카테고리의 다른 글
[Kotlin] Splash Screen (0) | 2020.08.07 |
---|---|
[Kotlin] StatusBar 투명색 (0) | 2020.08.05 |
[Kotlin] TabLayout, ViewPager in Fragment inside Fragment (0) | 2020.07.22 |
[Kotlin] Bottom Navigation bar (0) | 2020.07.06 |
[Kotlin] Facebook 소셜 로그인 (0) | 2020.06.29 |