由网友(现实旳沧桑)分享简介:我有一个自定义绘制的拇指一个搜索栏,我想隐藏它基于另一个控制我必须要能够显示/。I have a SeekBar with a custom drawable for the Thumb, and I would like to be able to show/hide it based on another con...
我有一个自定义绘制的拇指一个搜索栏,我想隐藏它基于另一个控制我必须要能够显示/。
I have a SeekBar with a custom drawable for the Thumb, and I would like to be able to show/hide it based on another control I have.
我试图加载从资源的绘制,然后使用SeekBar.setThumb()与绘制,或者为null。
I have tried loading the drawable from resources, and then using SeekBar.setThumb() with the drawable, or null.
这是隐藏它(设置为null),但我永远不能拿回来。
That hides it (the set to null), but I can never get it back.
推荐答案
要做到这一点,最好的方法是设置可绘制从XML拇指(因为我是做所有沿),然后当你想隐藏/显示拇指绘制,只需操纵它的alpha值:
The best way to do this is to set the drawable for the thumb from XML (as I was doing all along) and then when you want to hide/show the Thumb drawable, just manipulate it's alpha value:
// Hide the thumb drawable if the SeekBar is disabled
if (enabled) {
seekBar.getThumb().mutate().setAlpha(255);
} else {
seekBar.getThumb().mutate().setAlpha(0);
}
相关推荐
最新文章