如何在seekBar中调整拇指图像的大小?

时间:2015-08-05 18:03:09

标签: android seekbar

当进度发生变化时,我可以让拇指更改为mipmap中的不同图像,但我无法更改其大小。 如果我只是更改图像文件的大小,那么该栏将不会显示。 我确定其中一些行是不必要的,但我不知道哪一行:

Java(在OnFinishInflate中):

LevelListDrawable likey_bar_draw;
        likey_bar_draw = (LevelListDrawable) getResources().getDrawable(R.drawable.likey_bar_hearts);
        likey_bar_draw.setBounds(new Rect(0, 0, 50, 50));
        likey_bar_draw.setLevel(5);
        likeyBar.setThumb(likey_bar_draw);

        likeyBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                LevelListDrawable likey_bar_draw;
                likey_bar_draw = (LevelListDrawable) getResources().getDrawable(R.drawable.likey_bar_hearts);
                Integer progressInt = progress; //for some reason it won't let me convert progress to a string
                Log.d(TAG, "likey level: " + progressInt.toString()); //even though it's allegedly an integer...
                likey_bar_draw.setLevel(progress);
                seekBar.setThumb(likey_bar_draw);
            }

布局:

<SeekBar
        android:id="@+id/likey_bar"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:max="10"
        android:progress="5"
        android:thumb="@drawable/likey_bar_hearts"
        android:progressDrawable="@drawable/likey_bar_progress"
        android:layout_marginTop="20dp"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:minHeight="50dp"
        android:maxHeight="50dp" />

likey_bar_hearts xml:

<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:minLevel="0" android:maxLevel="0" android:drawable="@mipmap/heart_gray_100">
        <shape>
            <size android:height="40dp" android:width="40dp" />
            <solid android:color="@android:color/transparent" />
        </shape>
    </item>
...(more items similar to this)

帮助??

0 个答案:

没有答案