简体   繁体   English

将合成器外观应用到滑块?

[英]Applying a Synth Look and Feel to Sliders?

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. 它的尺寸为12x20,我通过以下代码使用合成器外观来应用它。 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"? 另外,按拇指的代码没有任何作用,我认为这是因为sliderThumbs没有“按下状态”吗? Is there a way to make the L&F change on a slider when it is pressed? 有没有办法在按下滑块时更改L&F? 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" />

Use Vector graphics. 使用矢量图形。 On one of my apps, I originally used png files, the same as you. 在我的一个应用程序中,我最初使用的png文件与您相同。 When I switched to Vector graphics, the edges didn't tear when used on smaller buttons. 当我切换到矢量图形时,在较小的按钮上使用时,边缘没有撕裂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM