【问题标题】:Android SwitchCompat thumb not alignedAndroid SwitchCompat 拇指未对齐
【发布时间】:2016-10-02 03:42:37
【问题描述】:

我正在尝试在 Android Studio 中使用 SwitchCompat,我把它放在 build.gradle 中:

compile 'com.android.support:appcompat-v7:21.+'

但拇指不在滑块的中心。

这是我的 xml:

<android.support.v7.widget.SwitchCompat
    android:id="@+id/allarme"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_gravity="right" />

你能帮帮我吗?

【问题讨论】:

  • 尝试移除边缘底部以便快速测试。
  • 尝试设置minHeightmaxHeight
  • @Skizo 也不走运......
  • 请尝试将其封装在框架布局中。然后删除除 id、width 和 height 之外的所有属性。将 layout_gravity 分配给框架布局(以及所需的边距)。
  • @Xyaren 同样的结果 :(

标签: java android android-appcompat switchcompat


【解决方案1】:

我终于找到了问题:appcompat(目前是 v21.0.3)中有一个 bug,它会影响 hdpi 设备。 更多:https://code.google.com/p/android/issues/detail?id=78262

解决方法: 将此文件复制到应用程序的 res/drawable-hdpi 中:https://www.mediafire.com/?6c7537yi73m1e6m

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-22
    • 2017-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多