本帖最后由 hedaogui 于 2011-10-28 14:56:47 编辑

解决方案 »

  1.   


    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/probardown">   
      <!-- 设置背景色图像资源 -->   
      <item android:id="@android:id/background" android:drawable="@drawable/grey" />   
      <!-- 设置第二级进度条颜色图像资源 -->   
      <item android:id="@android:id/secondaryProgress" android:drawable="@drawable/grey" />   
      <!-- 设置第一级进度条颜色图像资源 -->   
      <item android:id="@android:id/progress" android:drawable="@drawable/green" />   
    </layer-list>
    是不是这个的原因?我用<selector></selector>就可以的。。汗
      

  2.   


    在哪里用<selector></selector>
      

  3.   

    在drawable 里面创建xml文件。和你用的layer-list 是差不多的东西吧<?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
            <item android:state_selected="true" android:color="#000" />
            <item android:state_focused="true" android:color="#000" />
            <item android:state_pressed="true" android:color="#000" />
            <item android:color="#fff" />
    </selector>
    你改下试下。。应该是可以的
      

  4.   

    其他的java代码一样吗,感觉那几个item不太像用在progressbar上的,能问下你的是如何应用的,是用在什么什么控件上的,可以给我贴下关键的代码不
      

  5.   

    <?xml version="1.0" encoding="utf-8"?>
    <!-- Copyright (C) 2008 The Android Open Source Project     Licensed under the Apache License, Version 2.0 (the "License");     
    you may not use this file except in compliance with the License.     You may obtain a copy of the License at          
    http://www.apache.org/licenses/LICENSE-2.0     Unless required by applicable law or agreed to in writing, software     
    distributed under the License is distributed on an "AS IS" BASIS,     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.     
    See the License for the specific language governing permissions and     limitations under the License.--> 
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">        
    <item android:id="@android:id/background" >       
       
       <shape>            
       <corners android:radius="5dip" />            
       <gradient                    
       android:startColor="#ff9d9e9d"                    
       android:centerColor="#ff5a5d5a"                    
       android:centerY="0.75"                    
       android:endColor="#ff747674"                    
       android:angle="270"            
       />        
       </shape>
       </item>        
       <item android:id="@android:id/secondaryProgress">        
       <clip >            
               <shape>            
       <corners android:radius="5dip" />            
       <gradient                    
       android:startColor="#ff9d9e9d"                    
       android:centerColor="#ff5a5d5a"                    
       android:centerY="0.75"                    
       android:endColor="#ff747674"                    
       android:angle="270"            
       />        
       </shape>
       </clip>  
        </item>        
        <item android:id="@android:id/progress">        
         <clip>            
       <shape>                
       <corners android:radius="5dip" />                
       <gradient                   
       android:startColor="#ffffd300"                        
       android:centerColor="#ffffb600"                        
       android:centerY="0.75"                        
       android:endColor="#ffffcb00"                        
       android:angle="270"             
       />            
       </shape>        
       </clip> 
         </item>    
         </layer-list>
    这是我最后用的
    源文件地址http://www.girlcoding.com/2011/04/custom-horizontal-progressbar/#comment-512
      

  6.   

    补充一点加载图片的时候可以加载9patch图片。
    例如:
                   <item android:id="@android:id/background" >
                           <nine-patch android:src="@drawable/background"> </nine-patch> 
                    </item>
                    <item android:id="@android:id/progress">
    <clip>
    <nine-patch android:src="@drawable/progress"> </nine-patch>
    </clip> 
    </item>