TOC is not supported in this version (ex.Mobile)
One of the functions that I use often and not often is SeekBar. It is often applied when the maintenance options/settings are adjusted by magnification rather than numbers
Basic Usage
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<SeekBar
android:id="@+id/mSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
If you register SeekBar like this, the screen applied as below is exposed.
To use this in Activity, apply it as follows. This is the source that worked to call the current Progress value to LogCat when modifying SeekBar with SeekBar half-active.
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
// STEP01. Match the SeekBar of layout
SeekBar mSeekBar = findViewById(R.id.mSeekBar);
// CASE01. If SeekBar has a default value of 50%
mSeekBar.setProgress(50);
// CASE02. If you want to process SeekBar values when modifying them
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
Log.d("TAG", "Progress >> " + progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
How to change the SeekBar
If you want to change the color to SeekBar
First, add the corresponding sauce to <resources> in res > values > style.xml
<style name="SeekBarColor" parent="Widget.AppCompat.SeekBar">
<item name="colorAccent">#000000</item>
</style>
If you want to changThen add android:theme to SeekBar.
<SeekBar
android:id="@+id/mSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:theme="@style/SeekBarColor"
/>
[Android] How to use SeekBar
🇰🇷 Korean
2020.07.26 - [개발 창고/Android] - [Android] SeekBar 적용하기
[Android] SeekBar 적용하기
자주 쓰기도, 자주 쓰지 않기도 하는 기능 중 하나가 SeekBar인데요 주료 옵션/설정 등을 숫자가 아닌 배율로 조정할 경우 적용하는 경우가 많은데요 이렇게 SeekBar를 등록하면 아래와 같이 적용된
royzero.tistory.com
'개발 창고 > Android' 카테고리의 다른 글
[Android] 구글 플레이스토어 개발자 계정 등록방법 (8) | 2024.03.25 |
---|---|
[Android] How to apply SimpleAdapter to ListView (65) | 2024.03.04 |
[Android] How to use ArrayAdapter in ListView (55) | 2024.02.27 |
[Android] How to use multiple shapes (36) | 2024.02.19 |
[Android] 폰트(font) 적용하기 (7) | 2024.02.13 |