티스토리 뷰
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.java
package com.jwsoft.javaproject;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView tvProgress;
private TextView tvClick;
private SeekBar seekBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvProgress = findViewById(R.id.tvProgress);
tvClick = findViewById(R.id.tvClick);
seekBar = findViewById(R.id.seekBar);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
tvClick.setText("Start");
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
tvProgress.setText(Integer.toString(progress));
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
tvClick.setText("Stop");
}
});
}
}
'Android > Java' 카테고리의 다른 글
[Java] ExoPlayer (0) | 2020.08.15 |
---|---|
[Java] VideoView (0) | 2020.08.15 |
[Java] Glide (0) | 2020.08.10 |
[Java] NestedScrollView (0) | 2020.08.10 |
[Java] ProgressBar (0) | 2020.08.07 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 코틀린
- CoordinatorLayout
- java
- James Kim
- 안드로이드 #코틀린 #Android #Kotlin
- ViewModel
- Livedata
- 자바
- ArrayList
- TabLayout
- Intent
- Kotlin
- DataBinding
- fragment
- Android
- coroutine
- handler
- JSONArray
- Vue.js #Vue.js + javascript
- 안드로이드
- Architecture Pattern
- activity
- MVVM
- JSONObject
- View
- 혀가 길지 않은 개발자
- Design Pattern
- XML
- ViewPager2
- recyclerview
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함