当我禁用它时,我想将我的搜索栏设为灰色。 我知道我可以通过更改颜色以编程方式进行此更改,但我想知道是否可以直接在我的 xml Activity 布局中执行此操作。
事实上,在我的代码中我想这样写:
mySeekBarNuance.setEnabled(true);
我的搜索栏会自动变成灰色。 谢谢
最佳答案
这样做
在你的 styles.xml 中
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"> // or the themw you are using
...
...
<item name="android:seekBarStyle">@style/MySeekBarStyle</item>
</style>
还添加新样式
<style name="MySeekBarStyle" parent="android:Widget.SeekBar">
<item name="android:colorControlNormal">@color/gray</item> // put here the color for disable state
</style>
controlColorNormal
用于禁用状态,colorAccent
用于启用状态
关于java - 禁用时如何使搜索栏变灰?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55650940/