我正在尝试实现androidx SeekBarPreference,根据docs,我也许可以在我的xml中使用setMax属性,但在这样做时,我得到了以下错误:
在xml中:
<SeekBarPreference
app:key="preference_key"
app:title="@string/preference"
app:showSeekBarValue="true"
app:setMax="10"/>错误:
root_preferences.xml:53: AAPT: error: attribute setMax (aka
gls.dev.MyApplication:setMax) not found.然而,当在代码中设置属性时,它就像一个护身符:
findPreference<SeekBarPreference>("preference_key")?.apply {
max = 10
min = 1
seekBarIncrement = 1
isAdjustable = true
}发布于 2019-05-13 09:24:15
max属性目前只存在于android:命名空间中,因此您需要使用:
<SeekBarPreference
app:key="preference_key"
app:title="@string/preference"
app:showSeekBarValue="true"
android:max="10"/>发布于 2019-10-31 19:53:14
你可以这样设置你的搜索栏:
<SeekBarPreference
app:title="Choose value:"
app:defaultValue="2"
app:min="2"
app:seekBarIncrement="1"
android:max="12"
app:key="key"
app:adjustable="true"
app:isPreferenceVisible="true"
app:showSeekBarValue="true"/>您还需要将以下内容添加到根标记中:
xmlns:android="http://schemas.android.com/apk/res/android"发布于 2019-05-11 15:13:15
该属性是max而不是setMax。你必须这样做:
app:max="10"https://stackoverflow.com/questions/56086602
复制相似问题