Seekbar使用自定义9补丁图像进行进度和背景

时间:2015-02-03 10:20:16

标签: android seekbar nine-patch

我正在尝试使用自定义进度和背景来实现SeekBar。

搜索条

<SeekBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:id="@+id/seekBar"
            android:paddingLeft="2dp"
            android:paddingRight="2dp"
            android:thumbOffset="0dp"
            android:maxHeight="6dp"
            android:tag="seekbar"
            android:thumb="@drawable/circle_seekbar_player_fragment"                   android:progressDrawable="@drawable/styled_progress_player_fragment"/>

styled_progress_player_fragment.xml

<?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/seekbar_backgroun">
        </item>

    <!--<item android:id="@android:id/secondaryProgress">
        <scale
            android:drawable="@drawable/rounded_corners_seekbar_transparent"
            android:scaleWidth="100%" />
    </item>-->
    <item
        android:id="@android:id/progress">
        <scale
            android:drawable="@drawable/seekbar_progres"
            android:scaleWidth="100%"/>
    </item>

</layer-list>

背景seekbar_backgroun.9.png enter image description here 进度图片seekbar_progres.9.png enter image description here

在9patch窗口中,它可以根据需要进行缩放: enter image description here

但是在我的应用程序中,它表现得很奇怪,或者我可能没有正确行事 enter image description here

你能帮助我,所以我的搜索栏看起来很好吗

修改 问题解决了。问题是,当我使用ninepatch时,它使用px中的resolurion而不是dp,这就是它缩小的原因 我通过将这九张图片放到xxhdpi文件夹

来修复它

0 个答案:

没有答案