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

发布于 2024-09-18 18:49:29 字数 1286 浏览 0 评论 0原文

我有一堆滑块,我正在尝试对其应用自定义拇指。它的尺寸是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随梦而飞# 2024-09-25 18:49:29

使用矢量图形。在我的一个应用程序上,我最初使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文