未找到Androidx SeekBarPreference xml属性setMax

未找到Androidx SeekBarPreference xml属性setMax,android,xml,kotlin,android-preferences,Android,Xml,Kotlin,Android Preferences,根据xml中的setMax属性,我正在尝试实现androidx SeekBarPreference,但执行此操作时出现以下错误: 在xml中: <SeekBarPreference app:key="preference_key" app:title="@string/preference" app:showSeekBarValue="true" app:setMax="10"/> 但是,在代码中设置属性时,它就像一个符咒: findPreferen

根据xml中的
setMax
属性,我正在尝试实现androidx SeekBarPreference,但执行此操作时出现以下错误:

在xml中:

<SeekBarPreference
    app:key="preference_key"
    app:title="@string/preference"
    app:showSeekBarValue="true"
    app:setMax="10"/>
但是,在代码中设置属性时,它就像一个符咒:

findPreference<SeekBarPreference>("preference_key")?.apply {
    max = 10
    min = 1
    seekBarIncrement = 1
    isAdjustable = true
}
findReference(“首选项_键”)?应用{
最大值=10
最小值=1
请参见基准增量=1
isAdjustable=true
}

属性是
max
而不是
setMax
。你必须做到:

app:max="10"
你应该试试这个

在XML中

<SeekBarPreference
    app:key="preference_key"
    app:title="@string/preference"
    app:showSeekBarValue="true"
    app:max="10"/>


它将工作

当前只有android:namespace中存在
max
属性,因此您需要使用:

<SeekBarPreference
    app:key="preference_key"
    app:title="@string/preference"
    app:showSeekBarValue="true"
    android:max="10"/>

您可以这样设置搜索栏:

        <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"/>

我不适用于我,错误仍然存在
root\u首选项。xml:53:AAPT:error:attribute setMax(又名gls.dev.MyApplication:setMax)未找到。
错误是setMax,而不是max。你确定你将app:setMax更改为app:max吗?抱歉,我刚刚粘贴了与以前相同的错误,错误现在显示
root\u preferences.xml:54:AAPT:error:attribute max(又名gls.dev.MyApplication:max)未找到
尝试使用
android:max
而不是
app:max
,因为@Louis建议使用app:max=>
错误:attribute max未找到
,使用android:max=>
错误:未绑定前缀。
应用程序名称空间中不存在max属性有什么原因吗?我认为它应该,正如
SeekBarPreference
的所有其他属性一样。
        <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"