티스토리 뷰
res/drawable/seek_bar_thumb.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- 원모양의 시크바 컨트롤러 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false" >
<!-- 배경 -->
<solid
android:color="@android:color/white"/>
<!-- 크기 -->
<size
android:width="16dp"
android:height="16dp"/>
</shape>
res/drawable/seek_bar_progress.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/background">
<shape android:shape="line">
<stroke
android:width="4dp"
android:color="@android:color/holo_blue_bright"/>
</shape>
</item>
<item android:id="@+id/secondaryProgress">
<clip>
<shape android:shape="line">
<stroke
android:width="4dp"
android:color="@android:color/holo_blue_bright"/>
</shape>
</clip>
</item>
<item android:id="@+id/progress">
<clip>
<shape android:shape="line">
<stroke
android:width="4dp"
android:color="#FF541F"/>
</shape>
</clip>
</item>
</layer-list>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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:background="#68000000"
tools:context=".MainActivity">
<TextView
android:id="@+id/tvProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20"
android:textSize="50dp"
android:textStyle="italic"
android:textColor="@android:color/white"
android:layout_gravity="center"/>
<TextView
android:id="@+id/tvClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ready"
android:textSize="30dp"
android:textStyle="bold"
android:textColor="@android:color/white"
android:layout_gravity="center"
android:layout_marginTop="100dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_gravity="bottom"
android:orientation="horizontal" >
<SeekBar
android:id="@+id/seekBar"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:max="100"
android:progress="20"
android:thumb="@drawable/seek_bar_thumb"
android:progressDrawable="@drawable/seek_bar_progress"/>
</LinearLayout>
</FrameLayout>
MainActivity.kt
package com.jwsoft.kotlinproject
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.SeekBar
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
seekBar.setOnSeekBarChangeListener(object: SeekBar.OnSeekBarChangeListener {
override fun onStartTrackingTouch(seekBar: SeekBar?) {
tvClick.text = "Start"
}
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
tvProgress.text = progress.toString()
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
tvClick.text = "Stop"
}
})
}
}
'Android > Kotlin' 카테고리의 다른 글
[Kotlin] ExoPlayer (0) | 2020.08.15 |
---|---|
[Kotlin] VideoView (0) | 2020.08.15 |
[Kotlin] @JvmOverloads + CustomView (0) | 2020.08.14 |
[Kotlin] StickyHeader + RecyclerView (0) | 2020.08.14 |
[Kotlin] @JvmOverloads (0) | 2020.08.12 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- ViewPager2
- XML
- fragment
- 자바
- 혀가 길지 않은 개발자
- Intent
- MVVM
- recyclerview
- 안드로이드
- ViewModel
- Android
- James Kim
- java
- TabLayout
- JSONArray
- 안드로이드 #코틀린 #Android #Kotlin
- Architecture Pattern
- View
- activity
- Vue.js #Vue.js + javascript
- 코틀린
- DataBinding
- Kotlin
- CoordinatorLayout
- handler
- Design Pattern
- coroutine
- Livedata
- JSONObject
- ArrayList
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함