【发布时间】:2018-01-27 19:43:13
【问题描述】:
我想在我的 android 应用程序中使用 SeekBar。我的 minsdk 版本必须是 23。
编译器说 SeekBar 的 setMin 至少需要 API 级别 26。
对于简单的 SeekBar setMin,我需要一些特殊的支持库吗?
我在 Linux 上使用 Android Studio 3.0.1。我的 build.gradle 是这样的:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.zamek.boyler"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
我的布局 sn-p:
<SeekBar
android:id="@+id/sb_hysteresis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="15dp"/>
我的活动代码sn-ps:
import android.widget.SeekBar;
...
private SeekBar hysteresis;
...
this.hysteresis = findViewById(R.id.sb_hysteresis);
this.hysteresis.setMin(10); <--Compiler said:Call requires API level 26 (current min is 23): android.widget.AbsSeekBar#setMin
谢谢,
扎梅克
【问题讨论】:
-
是的,看来您需要 >= api 26 才能使用/设置该属性。更多内容请参见 link
-
谢谢,我在这里找到了一个简单的 FLoatSeekBar:gist.github.com/niusounds/9505361 它运行良好。