【问题标题】:Seekbar thumb being enlarged on tablet平板电脑上的 Seekbar 拇指被放大
【发布时间】:2016-04-17 01:53:01
【问题描述】:

我有一个垂直搜索栏,并使用自定义可绘制对象作为拇指。在手机上,一切正常,但在平板电脑上,搜索栏拇指图像被放大。下面是一些截图:

电话:http://i.imgur.com/Ca4wcav.png

平板电脑:http://i.imgur.com/7a5LRb4.png

这里是drawable的代码:

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

<item>

    <shape>
        <size
            android:height="30dp"
            android:width="20dp" />

        <solid android:color="@android:color/transparent"/>
    </shape>
</item>
<item android:drawable="@drawable/scroll_thumb" android:width="28dp" android:height="23dp" android:top="3dp">


</item>

</layer-list>

drawable/scroll_thumb 是400x300px左右的实际图片。

我尝试了一些我认为可行的方法,例如:

Drawable leftThumb = getDrawable(R.drawable.seekbar_thumb);
Drawable rightThumb = mRightSeek.getThumb();

leftThumb.setBounds(100, 100, 50, 50);
rightThumb.setBounds(0, 0, 0, 0);

mLeftSeek.setThumb(leftThumb);
mRightSeek.setThumb(rightThumb);

以上似乎都没有效果。造成这种扩大的原因是什么,解决方法是什么?

【问题讨论】:

    标签: android android-layout android-drawable android-seekbar xml-drawable


    【解决方案1】:

    可能是 dpi 兼容性问题。您需要将所有分辨率scroll_thumb 资源提供给对应的drawable-hdpi,drawable-xhdpi,drawable-xxhdpi 文件夹。或者将最高资源放到drawable-xxhdpi文件夹中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多