1、在drawable目录下新建XML文件progressbar_horizontal_red:

<?xml version="1.0" encoding="utf-8"?><!--Copyright (C) 2008 The Android Open Source Project Licensed under theApache License, Version 2.0 (the "License"); you may not use this fileexcept in compliance with the License. You may obtain a copy of theLicense at http://www.apache.org/licenses/LICENSE-2.0 Unless requiredby applicable law or agreed to in writing, software distributed underthe License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES ORCONDITIONS OF ANY KIND, either express or implied. See the License forthe specific language governing permissions and limitations under theLicense.--><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="#ff333333"android:centerColor="#ff4a4a4a" android:centerY="0.75"android:endColor="#ff333333" android:angle="270" /></shape></item><item android:id="@android:id/secondaryProgress"><clip><shape><corners android:radius="5dip" /><gradient android:startColor="#8000AADD"android:centerColor="#8000AADD" android:centerY="0.75"android:endColor="#8000AADD" android:angle="270" /></shape></clip></item><item android:id="@android:id/progress"><clip><shape><corners android:radius="5dip" /><gradient android:startColor="#fffa6b6b"android:centerColor="#ffff0000" android:centerY="0.75"android:endColor="#ffe80202" android:angle="270" /></shape></clip></item></layer-list>


2、在values目录下新建XML文件styles:
<?xml version="1.0" encoding="utf-8"?><resources>    <style name="progressbarStyle_Horizontal_Red" parent="android:Widget.ProgressBar.Horizontal">    <item name="android:indeterminateOnly">false</item>    <item name="android:progressDrawable">@drawable/progressbar_horizontal_red</item>    <item name="android:minHeight">12.0dp</item>    <item name="android:maxHeight">12.0dp</item>    </style></resources>


3、布局文件代码:
<ProgressBarandroid:layout_width="fill_parent"android:layout_height="wrap_content"style="@style/progressbarStyle_Horizontal_Red" />

运行起来之后可以发现水平进度条已经变成红色的了~

更多相关文章

  1. Android继承ViewGroup自定义流式布局
  2. 编译cubieboard android 源码过程详解之(四):extract-bsp
  3. android支持多分辨率屏幕
  4. 错误集录
  5. Android为ListView的Item设置不同的布局
  6. 解决Android(安卓)sdk manager无法访问google服务器更新的问题
  7. [android] 从 SDcard 中进行文件的读取操作,含中文和数字
  8. Android(安卓)9.0 http请求问题
  9. 解决 Android(安卓)N 上报错:android.os.FileUriExposedException

随机推荐

  1. [Android]调试webview
  2. 我来说说Android touch 系统的设计哲学
  3. (转)Android AndroidManifest.xml文件的and
  4. Android——自定义View类(一 )
  5. 原生Android也能做Web开发了
  6. Android -- 内存泄漏
  7. HTML5在Android(安卓)IOS等移动平台上的
  8. Android(安卓)Studio 2.0带来的新特性
  9. 用Dbus与android的bluz通信
  10. android按键静音键功能实现