自定义搜索栏时的数字格式异常

时间:2015-02-12 07:38:46

标签: android

我想更改搜索栏的搜索栏进度颜色和背景

下面是xml文件

搜索条

 <SeekBar
            android:id="@+id/sbVolumn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="false"
            android:layout_centerVertical="true"
            android:layout_margin="@dimen/small_margin"
            android:layout_toRightOf="@+id/ivSpeaker"
            android:indeterminate="false"
            android:progress="@drawable/playing_progress_bar_bg"
            android:thumb="@drawable/playing_volumn_bar" />

playing_progress_bar_bg

<?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/playing_seekbar_background_fill"/>
    <item android:id="@android:id/progress">
        <clip android:drawable="@drawable/playing_seekbar_progress_fill" />
    </item>

</layer-list>

playing_seekbar_background_fill

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

    <gradient
        android:angle="90"
        android:centerColor="#FF555555"
        android:endColor="#FF555555"
        android:startColor="#FF555555" />

    <corners android:radius="5px" />

    <stroke
        android:width="2dp"
        android:color="#50999999" />
    <stroke
        android:width="1dp"
        android:color="#70555555" />

</shape>

playing_seekbar_progress_fill

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

    <gradient
        android:angle="180"
        android:centerColor="#FFB80000"
        android:endColor="#FFFF4400"
        android:startColor="#FF470000" />

    <corners android:radius="5px" />

    <stroke
        android:width="2dp"
        android:color="#50999999" />
    <stroke
        android:width="1dp"
        android:color="#70555555" />

</shape>

错误的 logcat

02-12 13:02:32.059: E/AndroidRuntime(24024): android.view.InflateException: Binary XML file line #56: Error inflating class android.widget.SeekBar
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.view.LayoutInflater.createView(LayoutInflater.java:620)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at com.example.achessapp.fragment.discover.listen_look_learn.motivational.player.PlayingFragment.onCreateView(PlayingFragment.java:37)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.app.Fragment.performCreateView(Fragment.java:1700)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.app.BackStackRecord.run(BackStackRecord.java:698)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.os.Handler.handleCallback(Handler.java:808)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.os.Handler.dispatchMessage(Handler.java:103)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.os.Looper.loop(Looper.java:193)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.app.ActivityThread.main(ActivityThread.java:5395)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at java.lang.reflect.Method.invokeNative(Native Method)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at java.lang.reflect.Method.invoke(Method.java:515)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:837)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at dalvik.system.NativeStart.main(Native Method)
02-12 13:02:32.059: E/AndroidRuntime(24024): Caused by: java.lang.reflect.InvocationTargetException
02-12 13:02:32.059: E/AndroidRuntime(24024):    at java.lang.reflect.Constructor.constructNative(Native Method)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.view.LayoutInflater.createView(LayoutInflater.java:594)
02-12 13:02:32.059: E/AndroidRuntime(24024):    ... 23 more
02-12 13:02:32.059: E/AndroidRuntime(24024): Caused by: java.lang.NumberFormatException: Invalid int: "res/drawable/playing_progress_bar_bg.xml"
02-12 13:02:32.059: E/AndroidRuntime(24024):    at java.lang.Integer.invalidInt(Integer.java:137)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at java.lang.Integer.parse(Integer.java:374)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at java.lang.Integer.parseInt(Integer.java:365)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:122)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.content.res.TypedArray.getInt(TypedArray.java:267)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.widget.ProgressBar.<init>(ProgressBar.java:312)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.widget.ProgressBar.<init>(ProgressBar.java:262)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.widget.AbsSeekBar.<init>(AbsSeekBar.java:69)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.widget.SeekBar.<init>(SeekBar.java:83)
02-12 13:02:32.059: E/AndroidRuntime(24024):    at android.widget.SeekBar.<init>(SeekBar.java:79)
02-12 13:02:32.059: E/AndroidRuntime(24024):    ... 26 more

1 个答案:

答案 0 :(得分:4)

你应该改变

 android:progress="@drawable/playing_progress_bar_bg"

 android:progressDrawable="@drawable/playing_progress_bar_bg"

您应始终以整数值提供进度。android:progress="0"