【问题标题】:android seekbar progressdrawable: background bitmap doesnt stretch (height)android seekbar进度可绘制:背景位图不拉伸(高度)
【发布时间】:2013-01-09 23:42:11
【问题描述】:

我的布局xml如下:

 <SeekBar
        android:id="@+id/progress"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_margin="10dp"
        android:gravity="center"
        android:progressDrawable="@drawable/progressbar_drawable"
        android:progress="50"
        android:thumb="@drawable/progressbar_handle_selector"
        android:layout_toLeftOf="@+id/showChat"
        android:layout_toRightOf="@+id/play" />

Seekbar的进度drawable如下:

@drawable/progressbar_drawable

  <?xml version="1.0" encoding="utf-8"?>
  <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

  <item android:id="@android:id/background" android:drawable="@drawable/bg_progressbar_9patch"/>
  <item android:id="@android:id/progress">
    <clip>
        <shape>
            <gradient
                android:angle="90"
                android:endColor="#d9b546"
                android:startColor="#cc520f" />
        </shape>
    </clip>
  </item>

  </layer-list>

因此,与进度可绘制对象(橙色)相比,背景位图(白色)不会在高度上拉伸并且仍然太低,这是一个示例:

更重要的是,它在不同的屏幕上看起来不同:背景位图与进度可绘制相比具有不同的高度。例如(另一个屏幕):

我的问题是:为什么进度和背景可绘制对象(橙色和白色条纹)总是具有相同的高度以及如何使它们具有相同的高度?


更新

PNG资源:

【问题讨论】:

    标签: android seekbar


    【解决方案1】:

    我从您的图像创建了 9-patch 并将其放在 drawable-hdpi 文件夹中,一切看起来都很好...我在 eclipse ui 预览器中有一些工件,但在设备上一切正常...

    https://dl.dropbox.com/u/13106986/bg_progressbar_patch.9.png

    【讨论】:

    • 奇怪,把相关资源做个存档,分享一下。我看看有什么问题)
    • 它适用于 api 11+,我明天会更精确地测试它的 api 8-10。
    • 看来,9-patch 在 android 2.2 上启动时不会拉伸 - 可能是什么问题?
    • 我不知道。我会在 2.2 版本上检查它
    猜你喜欢
    • 1970-01-01
    • 2017-06-19
    • 1970-01-01
    • 2012-03-21
    • 2018-04-09
    • 2013-05-10
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    相关资源
    最近更新 更多