在 Lollipop 之前的 Android 版本中,有什么方法可以使开关的拇指高度大于轨道高度?
我基本上是在尝试在 Kitkat 中创建一个类似 Material 设计的开关小部件(和旧版本 - 这里的问题是默认情况下拇指“适合”在轨道内)。我已经为此工作了很长一段时间,但我似乎无法得出正确的设计。
我遵循了这篇 SO 帖子中的解决方案:How to change the size of a Switch Widget .
如有任何建议或解决方案,我们将不胜感激。
最佳答案
我向我的轨道可绘制形状添加了一个透明笔触,这导致轨道周围出现填充:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/track_color"/>
<size android:height="@dimen/track_height" />
<size android:width="@dimen/track_width" />
<!-- results in the track looking smaller than the thumb -->
<stroke
android:width="6dp"
android:color="#00ffffff"/>
</shape>
关于Android 开关 - 使拇指高度大于轨道高度,如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29115057/