如何从 Android 中按下的滑块中去除发光? [英] How can I remove the glow from a pressed slider in Android?
问题描述
我的 Android 应用中有一个自定义的 SeekBar.当拇指按下时,它周围会出现一种光晕.光环在长时间按下时也会发生变化.我想消除这种光环效应.
I have a custom SeekBar in my Android app. When the thumb is pressed, a kind of halo appears around it. The halo also modifies when it is pressed for a long time. I would like to eliminate this halo effect.
我看过这个 SeekBar 文档 https://developer.android.com/reference/android/widget/SeekBar.html 但看不到任何可以消除它的东西.
I have looked at this SeekBar documentation https://developer.android.com/reference/android/widget/SeekBar.html but do not see anything that can eliminate it.
所以,我的问题是:如何在按下搜索栏拇指时禁用这种光环"效果?
So, my question is: How can I disable this "halo" effect when the seekbar thumb is pressed?
在这个截图中,你可以看到我试图消除的白色光晕.
In this screenshot, you can see the white halo I am trying to eliminate.
提前致谢!
添加 SeekBar xml:
adding SeekBar xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clip_connect_list_item"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_radius"
android:background="@drawable/slider_base"
android:orientation="horizontal"
android:clickable="true">
<SeekBar android:id="@+id/seekBar1"
android:max="100"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumbOffset="0dp"
android:layout_gravity="center_vertical"
android:progressDrawable="@color/transparent"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
>
</SeekBar>
</LinearLayout>
推荐答案
参加聚会有点晚了,但是将主题的 colorControlHighlight
属性设置为 transparent
很有效我:
A bit late to the party, but setting the colorControlHighlight
property to transparent
on one's theme worked for me:
<style name="Base.AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- This is necessary to remove outward glow appearing on seekbar -->
<item name="colorControlHighlight">@android:color/transparent</item>
</style>
此相同颜色用于其他 UI 元素上的涟漪效果,因此建议用户自行决定.
This same color is used for the ripple effect on other UI elements, so user discretion advised.
这篇关于如何从 Android 中按下的滑块中去除发光?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!