将合成器外观应用于滑块?
我有一堆滑块,我正在尝试对其应用自定义拇指。它的尺寸是 12x20,我使用下面的代码使用合成器外观来应用它。这可以正确显示水平滑块的拇指,但是一旦我制作了垂直滑块,拇指的边缘就会变形。有没有更好的方法来做到这一点?另外,拇指按下的代码不会执行任何操作,我认为原因是 sliderThumbs 没有“按下状态”?有没有办法让滑块按下时 L&F 发生变化?预先感谢!
干杯, 卢卡斯
<!-- Make and Bind a SliderThumb style -->
<style id="sliderStyle">
<state>
<property key="Slider.paintValue" type="boolean" value="false"/>
<property key="Slider.thumbWidth" type="integer" value="12"/>
<property key="Slider.thumbHeight" type="integer" value="21"/>
</state>
</style>
<bind style="sliderStyle" type="region" key="slider" />
<style id="SliderTrackStyle">
<opaque value="FALSE"/>
</style>
<bind style="SliderTrackStyle" type="region" key="sliderTrack" />
<style id="sliderThumbStyle">
<state>
<imagePainter method="sliderThumbBackground" path="Images/SliderThumb.png"
sourceInsets="0 0 0 0"/>
</state>
<state value="PRESSED">
<imagePainter method="sliderThumbBackground" path="Images/SliderThumbPressed.png"
sourceInsets="0 0 0 0"/>
</state>
</style>
<bind style="sliderThumbStyle" type="region" key="sliderThumb" />
I have a bunch of sliders that I am trying to apply a custom thumb to. The dimensions of it are 12x20, and I am applying it using a synth look and feel with the code below. This displays the thumb correctly for horizontal sliders, but once I make a vertical one the thumb gets distorted on the edges. Is there any better way to do this? Also, The thumb pressed code doesn't do anything, I would assume the reason for that is that sliderThumbs don't have a "pressed state"? Is there a way to make the L&F change on a slider when it is pressed? Thanks beforehand!!!
Cheers,
Lukas
<!-- Make and Bind a SliderThumb style -->
<style id="sliderStyle">
<state>
<property key="Slider.paintValue" type="boolean" value="false"/>
<property key="Slider.thumbWidth" type="integer" value="12"/>
<property key="Slider.thumbHeight" type="integer" value="21"/>
</state>
</style>
<bind style="sliderStyle" type="region" key="slider" />
<style id="SliderTrackStyle">
<opaque value="FALSE"/>
</style>
<bind style="SliderTrackStyle" type="region" key="sliderTrack" />
<style id="sliderThumbStyle">
<state>
<imagePainter method="sliderThumbBackground" path="Images/SliderThumb.png"
sourceInsets="0 0 0 0"/>
</state>
<state value="PRESSED">
<imagePainter method="sliderThumbBackground" path="Images/SliderThumbPressed.png"
sourceInsets="0 0 0 0"/>
</state>
</style>
<bind style="sliderThumbStyle" type="region" key="sliderThumb" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用矢量图形。在我的一个应用程序上,我最初使用 png 文件,和你一样。当我切换到矢量图形时,在较小的按钮上使用时边缘不会撕裂。
Use Vector graphics. On one of my apps, I originally used png files, the same as you. When I switched to Vector graphics, the edges didn't tear when used on smaller buttons.