gpt4 book ai didi

android - 使 seekbar thumb hitbox 更大

转载 作者:行者123 更新时间:2023-11-29 01:46:41 26 4
gpt4 key购买 nike

我定制了一个看起来像这样的搜索栏

enter image description here

问题是很难捕获 slider 。所以我想做的是增加拇指的碰撞箱以使其更容易。我尝试了一些东西,但总是弄乱了搜索栏的外观。我有什么想法可以做到这一点吗?

布局.xml

<SeekBar
android:id="@+id/xxx"
style="@style/SeekBar"
android:layout_width="@dimen/pixel_130dp"
android:layout_below="@+id/name_textview"
android:layout_centerHorizontal="true" />

样式.xml

<style name="SeekBar">
<item name="android:layout_height">@dimen/pixel_20dp</item>
<item name="android:maxHeight">@dimen/pixel_20dp</item>
<item name="android:minHeight">@dimen/pixel_20dp</item>
<item name="android:thumb">@drawable/seek_bar_thumb</item>
<item name="android:paddingLeft">@dimen/pixel_5dp</item>
<item name="android:paddingRight">@dimen/pixel_5dp</item>
<item name="android:paddingTop">@dimen/pixel_2dp</item>
<item name="android:paddingBottom">@dimen/pixel_2dp</item>
<item name="android:progressDrawable">@drawable/seek_bar_progress_drawable</item>
</style>

seek_bar_thumb.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item>
<shape>
<size
android:height="@dimen/pixel_16dp"
android:width="@dimen/pixel_25dp" />

<solid android:color="@android:color/transparent" />
</shape>
</item>
<item android:drawable="@drawable/slider_thumb"/>

</layer-list>

最佳答案

好吧,因为显然没有更聪明的方法来做到这一点,这就是我现在所做的;我找到的唯一解决方案是在拇指图像周围添加一个透明区域。我将其大小加倍并将 thumbOffset 参数添加到 Seekbar。这似乎不是最佳解决方案,但至少在我的情况下有效。

关于android - 使 seekbar thumb hitbox 更大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21005319/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com