[
  {
    "path": ".gitignore",
    "content": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\n\n# Gradle files\n.gradle/\nbuild/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Log Files\n*.log\n"
  },
  {
    "path": "LICENSE",
    "content": "Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n"
  },
  {
    "path": "README.md",
    "content": "# Android-ColorTrackView\n字体或者图片可以逐渐染色和逐渐褪色的动画效果\n\n# 使用\n\n```xml\n <com.zhy.view.ColorTrackView\n        android:id=\"@+id/id_changeTextColorView\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_centerInParent=\"true\"\n        android:layout_centerVertical=\"true\"\n        android:padding=\"20dp\"\n        android:background=\"#44ff0000\"\n        android:gravity=\"center_vertical\"\n        zhy:progress=\"0\"\n        zhy:direction=\"left\"\n        zhy:text=\"张鸿洋\"\n        zhy:text_change_color=\"#ffff0000\"\n        zhy:text_origin_color=\"#ff000000\"\n        zhy:text_size=\"60sp\" />\n```\n\n注：zhy为命名空间，xmlns:zhy=\"http://schemas.android.com/apk/res-auto\"，可自由修改。\n\n* `progress`  [0.0f , 1.0f]\n* `text` 绘制的文本\n* `text_change_color`目标颜色\n* `text_origin_color`原始颜色\n* `text_size`字体大小\n* `direction `方向，枚举类型，支持：left,right,top,bottom\n\n# 效果图\n\n## 简单使用\n![](sample_ColorTrackeView/sc.gif)\n\n## 结合ViewPager\n![](sample_ColorTrackeView/changecolortvdemo.gif)\n\n\n# 关于我\n[我的博客地址](http://blog.csdn.net/lmj623565791)\n\n\n"
  },
  {
    "path": "library_ColorTrackView/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<classpath>\r\n\t<classpathentry kind=\"src\" path=\"src\"/>\r\n\t<classpathentry kind=\"src\" path=\"gen\"/>\r\n\t<classpathentry kind=\"con\" path=\"com.android.ide.eclipse.adt.ANDROID_FRAMEWORK\"/>\r\n\t<classpathentry exported=\"true\" kind=\"con\" path=\"com.android.ide.eclipse.adt.LIBRARIES\"/>\r\n\t<classpathentry exported=\"true\" kind=\"con\" path=\"com.android.ide.eclipse.adt.DEPENDENCIES\"/>\r\n\t<classpathentry kind=\"output\" path=\"bin/classes\"/>\r\n</classpath>\r\n"
  },
  {
    "path": "library_ColorTrackView/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>library_ColorTrackView</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.ApkBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "library_ColorTrackView/.settings/org.eclipse.core.resources.prefs",
    "content": "eclipse.preferences.version=1\nencoding/<project>=UTF-8\n"
  },
  {
    "path": "library_ColorTrackView/.settings/org.eclipse.jdt.core.prefs",
    "content": "eclipse.preferences.version=1\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\norg.eclipse.jdt.core.compiler.compliance=1.6\norg.eclipse.jdt.core.compiler.source=1.6\n"
  },
  {
    "path": "library_ColorTrackView/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n    package=\"com.zhy.sample_color_change_text\"\r\n    android:versionCode=\"1\"\r\n    android:versionName=\"1.0\" >\r\n\r\n    <uses-sdk\r\n        android:minSdkVersion=\"8\"\r\n        android:targetSdkVersion=\"19\" />\r\n\r\n    <application\r\n        android:allowBackup=\"true\"\r\n        android:icon=\"@drawable/ic_launcher\"\r\n        android:label=\"@string/app_name\"\r\n        android:theme=\"@style/AppTheme\" >\r\n        <activity\r\n            android:name=\"com.zhy.sample_color_change_text.MainActivity\"\r\n            android:label=\"@string/app_name\" >\r\n            <intent-filter>\r\n                <action android:name=\"android.intent.action.MAIN\" />\r\n\r\n                <category android:name=\"android.intent.category.LAUNCHER\" />\r\n            </intent-filter>\r\n        </activity>\r\n    </application>\r\n\r\n</manifest>\r\n"
  },
  {
    "path": "library_ColorTrackView/proguard-project.txt",
    "content": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in that file.\n#\n# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in ${sdk.dir}/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the ProGuard\n# include property in project.properties.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "library_ColorTrackView/project.properties",
    "content": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# This file must be checked in Version Control Systems.\n#\n# To customize properties used by the Ant build system edit\n# \"ant.properties\", and override values to adapt the script to your\n# project structure.\n#\n# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):\n#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt\n\n# Project target.\ntarget=android-19\nandroid.library=true\n"
  },
  {
    "path": "library_ColorTrackView/res/menu/main.xml",
    "content": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\r\n\r\n    <item\r\n        android:id=\"@+id/action_settings\"\r\n        android:orderInCategory=\"100\"\r\n        android:showAsAction=\"never\"\r\n        android:title=\"@string/action_settings\"/>\r\n\r\n</menu>\r\n"
  },
  {
    "path": "library_ColorTrackView/res/values/attr.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <attr name=\"text\" format=\"string\" />\n    <attr name=\"text_size\" format=\"dimension\" />\n    <attr name=\"text_origin_color\" format=\"color|reference\" />\n    <attr name=\"text_change_color\" format=\"color|reference\" />\n    <attr name=\"progress\" format=\"float\" />\n    <attr name=\"direction\">\n        <enum name=\"left\" value=\"0\" />\n        <enum name=\"right\" value=\"1\" />\n        <enum name=\"top\" value=\"2\" />\n        <enum name=\"bottom\" value=\"3\" />\n    </attr>\n\n    <declare-styleable name=\"ColorTrackView\">\n        <attr name=\"text\" />\n        <attr name=\"text_size\" />\n        <attr name=\"text_origin_color\" />\n        <attr name=\"text_change_color\" />\n        <attr name=\"progress\" />\n        <attr name=\"direction\" />\n    </declare-styleable>\n\n</resources>"
  },
  {
    "path": "library_ColorTrackView/res/values/dimens.xml",
    "content": "<resources>\r\n\r\n    <!-- Default screen margins, per the Android Design guidelines. -->\r\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\r\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\r\n\r\n</resources>\r\n"
  },
  {
    "path": "library_ColorTrackView/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\r\n\r\n    <string name=\"app_name\">sample_color_change_text</string>\r\n    <string name=\"action_settings\">Settings</string>\r\n    <string name=\"hello_world\">Hello world!</string>\r\n\r\n</resources>\r\n"
  },
  {
    "path": "library_ColorTrackView/res/values/styles.xml",
    "content": "<resources>\r\n\r\n    <!--\r\n        Base application theme, dependent on API level. This theme is replaced\n        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.\r\n    -->\r\n    <style name=\"AppBaseTheme\" parent=\"android:Theme.Light\">\r\n        <!--\r\n            Theme customizations available in newer API levels can go in\n            res/values-vXX/styles.xml, while customizations related to\n            backward-compatibility can go here.\r\n        -->\r\n    </style>\r\n\r\n    <!-- Application theme. -->\r\n    <style name=\"AppTheme\" parent=\"AppBaseTheme\">\r\n        <!-- All customizations that are NOT specific to a particular API-level can go here. -->\r\n    </style>\r\n\r\n</resources>\r\n"
  },
  {
    "path": "library_ColorTrackView/res/values-sw600dp/dimens.xml",
    "content": "<resources>\r\n\r\n    <!--\r\n         Customize dimensions originally defined in res/values/dimens.xml (such as\n         screen margins) for sw600dp devices (e.g. 7\" tablets) here.\r\n    -->\r\n\r\n</resources>\r\n"
  },
  {
    "path": "library_ColorTrackView/res/values-sw720dp-land/dimens.xml",
    "content": "<resources>\r\n\r\n    <!--\r\n         Customize dimensions originally defined in res/values/dimens.xml (such as\n         screen margins) for sw720dp devices (e.g. 10\" tablets) in landscape here.\r\n    -->\r\n    <dimen name=\"activity_horizontal_margin\">128dp</dimen>\r\n\r\n</resources>\r\n"
  },
  {
    "path": "library_ColorTrackView/res/values-v11/styles.xml",
    "content": "<resources>\r\n\r\n    <!--\r\n        Base application theme for API 11+. This theme completely replaces\n        AppBaseTheme from res/values/styles.xml on API 11+ devices.\r\n    -->\r\n    <style name=\"AppBaseTheme\" parent=\"android:Theme.Holo.Light\">\r\n        <!-- API 11 theme customizations can go here. -->\r\n    </style>\r\n\r\n</resources>\r\n"
  },
  {
    "path": "library_ColorTrackView/res/values-v14/styles.xml",
    "content": "<resources>\r\n\r\n    <!--\r\n        Base application theme for API 14+. This theme completely replaces\n        AppBaseTheme from BOTH res/values/styles.xml and\n        res/values-v11/styles.xml on API 14+ devices.\r\n    -->\r\n    <style name=\"AppBaseTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\">\r\n        <!-- API 14 theme customizations can go here. -->\r\n    </style>\r\n\r\n</resources>\r\n"
  },
  {
    "path": "library_ColorTrackView/src/com/zhy/view/ColorTrackView.java",
    "content": "package com.zhy.view;\r\n\r\nimport android.content.Context;\r\nimport android.content.res.TypedArray;\r\nimport android.graphics.Canvas;\r\nimport android.graphics.Paint;\r\nimport android.graphics.Paint.FontMetrics;\r\nimport android.graphics.Paint.Style;\r\nimport android.graphics.Rect;\r\nimport android.os.Bundle;\r\nimport android.os.Parcelable;\r\nimport android.util.AttributeSet;\r\nimport android.util.TypedValue;\r\nimport android.view.View;\r\n\r\nimport com.zhy.sample_color_change_text.R;\r\n\r\n/**\r\n * \r\n * @author zhy\r\n * \r\n */\r\npublic class ColorTrackView extends View {\r\n\r\n\tprivate int mTextStartX;\r\n\tprivate int mTextStartY;\r\n\r\n\tpublic enum Direction {\r\n\t\tLEFT, RIGHT, TOP, BOTTOM;\r\n\t}\r\n\r\n\tprivate int mDirection = DIRECTION_LEFT;\r\n\r\n\tprivate static final int DIRECTION_LEFT = 0;\r\n\tprivate static final int DIRECTION_RIGHT = 1;\r\n\tprivate static final int DIRECTION_TOP = 2;\r\n\tprivate static final int DIRECTION_BOTTOM = 3;\r\n\r\n\tpublic void setDirection(int direction) {\r\n\t\tmDirection = direction;\r\n\t}\r\n\r\n\tprivate String mText = \"张鸿洋\";\r\n\tprivate Paint mPaint;\r\n\tprivate int mTextSize = sp2px(30);\r\n\r\n\tprivate int mTextOriginColor = 0xff000000;\r\n\tprivate int mTextChangeColor = 0xffff0000;\r\n\r\n\tprivate Rect mTextBound = new Rect();\r\n\tprivate int mTextWidth;\r\n\tprivate int mTextHeight;\r\n\r\n\tprivate float mProgress;\r\n\r\n\tpublic ColorTrackView(Context context) {\r\n\t\tsuper(context, null);\r\n\t}\r\n\r\n\tpublic ColorTrackView(Context context, AttributeSet attrs) {\r\n\t\tsuper(context, attrs);\r\n\r\n\t\tmPaint = new Paint(Paint.ANTI_ALIAS_FLAG);\r\n\r\n\t\tTypedArray ta = context.obtainStyledAttributes(attrs,\r\n\t\t\t\tR.styleable.ColorTrackView);\r\n\t\tmText = ta.getString(R.styleable.ColorTrackView_text);\r\n\t\tmTextSize = ta.getDimensionPixelSize(\r\n\t\t\t\tR.styleable.ColorTrackView_text_size, mTextSize);\r\n\t\tmTextOriginColor = ta.getColor(\r\n\t\t\t\tR.styleable.ColorTrackView_text_origin_color, mTextOriginColor);\r\n\t\tmTextChangeColor = ta.getColor(\r\n\t\t\t\tR.styleable.ColorTrackView_text_change_color, mTextChangeColor);\r\n\t\tmProgress = ta.getFloat(R.styleable.ColorTrackView_progress, 0);\r\n\r\n\t\tmDirection = ta\r\n\t\t\t\t.getInt(R.styleable.ColorTrackView_direction, mDirection);\r\n\r\n\t\tta.recycle();\r\n\r\n\t\tmPaint.setTextSize(mTextSize);\r\n\r\n\t}\r\n\r\n\t@Override\r\n\tprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\r\n\r\n\t\tmeasureText();\r\n\r\n\t\tint width = measureWidth(widthMeasureSpec);\r\n\t\tint height = measureHeight(heightMeasureSpec);\r\n\t\tsetMeasuredDimension(width, height);\r\n\r\n\t\tmTextStartX = getMeasuredWidth() / 2 - mTextWidth / 2;\r\n\t\tmTextStartY = getMeasuredHeight() / 2 - mTextHeight / 2;\r\n\t}\r\n\r\n\tprivate int measureHeight(int measureSpec) {\r\n\t\tint mode = MeasureSpec.getMode(measureSpec);\r\n\t\tint val = MeasureSpec.getSize(measureSpec);\r\n\t\tint result = 0;\r\n\t\tswitch (mode) {\r\n\t\tcase MeasureSpec.EXACTLY:\r\n\t\t\tresult = val;\r\n\t\t\tbreak;\r\n\t\tcase MeasureSpec.AT_MOST:\r\n\t\tcase MeasureSpec.UNSPECIFIED:\r\n\t\t\tresult = mTextBound.height();\r\n\t\t\tresult += getPaddingTop() + getPaddingBottom();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tresult = mode == MeasureSpec.AT_MOST ? Math.min(result, val) : result;\r\n\t\treturn result;\r\n\t}\r\n\r\n\tprivate int measureWidth(int measureSpec) {\r\n\t\tint mode = MeasureSpec.getMode(measureSpec);\r\n\t\tint val = MeasureSpec.getSize(measureSpec);\r\n\t\tint result = 0;\r\n\t\tswitch (mode) {\r\n\t\tcase MeasureSpec.EXACTLY:\r\n\t\t\tresult = val;\r\n\t\t\tbreak;\r\n\t\tcase MeasureSpec.AT_MOST:\r\n\t\tcase MeasureSpec.UNSPECIFIED:\r\n\t\t\t// result = mTextBound.width();\r\n\t\t\tresult = mTextWidth;\r\n\t\t\tresult += getPaddingLeft() + getPaddingRight();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tresult = mode == MeasureSpec.AT_MOST ? Math.min(result, val) : result;\r\n\t\treturn result;\r\n\t}\r\n\r\n\tprivate void measureText() {\r\n\t\tmTextWidth = (int) mPaint.measureText(mText);\r\n\t\tFontMetrics fm = mPaint.getFontMetrics();\r\n\t\tmTextHeight = (int) Math.ceil(fm.descent - fm.top);\r\n\r\n\t\tmPaint.getTextBounds(mText, 0, mText.length(), mTextBound);\r\n\t\tmTextHeight = mTextBound.height();\r\n\t}\r\n\r\n\tpublic void reverseColor() {\r\n\t\tint tmp = mTextOriginColor;\r\n\t\tmTextOriginColor = mTextChangeColor;\r\n\t\tmTextChangeColor = tmp;\r\n\t}\r\n\r\n\t@Override\r\n\tprotected void onDraw(Canvas canvas) {\r\n\t\tsuper.onDraw(canvas);\r\n\r\n\t\tint r = (int) (mProgress * mTextWidth + mTextStartX);\r\n\t\tint t = (int) (mProgress * mTextHeight + mTextStartY);\r\n\r\n\t\tif (mDirection == DIRECTION_LEFT) {\r\n\t\t\tdrawChangeLeft(canvas, r);\r\n\t\t\tdrawOriginLeft(canvas, r);\r\n\t\t} else if (mDirection == DIRECTION_RIGHT) {\r\n\t\t\tdrawOriginRight(canvas, r);\r\n\t\t\tdrawChangeRight(canvas, r);\r\n\t\t} else if (mDirection == DIRECTION_TOP) {\r\n\t\t\tdrawOriginTop(canvas, t);\r\n\t\t\tdrawChangeTop(canvas, t);\r\n\t\t} else {\r\n\t\t\tdrawOriginBottom(canvas, t);\r\n\t\t\tdrawChangeBottom(canvas, t);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tprivate boolean debug = false;\r\n\r\n\tprivate void drawText_h(Canvas canvas, int color, int startX, int endX) {\r\n\t\tmPaint.setColor(color);\r\n\t\tif (debug) {\r\n\t\t\tmPaint.setStyle(Style.STROKE);\r\n\t\t\tcanvas.drawRect(startX, 0, endX, getMeasuredHeight(), mPaint);\r\n\t\t}\r\n\t\tcanvas.save(Canvas.CLIP_SAVE_FLAG);\r\n\t\tcanvas.clipRect(startX, 0, endX, getMeasuredHeight());// left, top,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// right, bottom\r\n\t\tcanvas.drawText(mText, mTextStartX,\r\n\t\t\t\tgetMeasuredHeight() / 2\r\n\t\t\t\t\t\t- ((mPaint.descent() + mPaint.ascent()) / 2), mPaint);\r\n\t\tcanvas.restore();\r\n\t}\r\n\r\n\tprivate void drawText_v(Canvas canvas, int color, int startY, int endY) {\r\n\t\tmPaint.setColor(color);\r\n\t\tif (debug) {\r\n\t\t\tmPaint.setStyle(Style.STROKE);\r\n\t\t\tcanvas.drawRect(0, startY, getMeasuredWidth(), endY, mPaint);\r\n\t\t}\r\n\r\n\t\tcanvas.save(Canvas.CLIP_SAVE_FLAG);\r\n\t\tcanvas.clipRect(0, startY, getMeasuredWidth(), endY);// left, top,\r\n\t\tcanvas.drawText(mText, mTextStartX,\r\n\t\t\t\tgetMeasuredHeight() / 2\r\n\t\t\t\t\t\t- ((mPaint.descent() + mPaint.ascent()) / 2), mPaint);\r\n\t\tcanvas.restore();\r\n\t}\r\n\r\n\tprivate void drawChangeLeft(Canvas canvas, int r) {\r\n\t\tdrawText_h(canvas, mTextChangeColor, mTextStartX,\r\n\t\t\t\t(int) (mTextStartX + mProgress * mTextWidth));\r\n\t}\r\n\r\n\tprivate void drawOriginLeft(Canvas canvas, int r) {\r\n\t\tdrawText_h(canvas, mTextOriginColor, (int) (mTextStartX + mProgress\r\n\t\t\t\t* mTextWidth), mTextStartX + mTextWidth);\r\n\t}\r\n\r\n\tprivate void drawChangeRight(Canvas canvas, int r) {\r\n\t\tdrawText_h(canvas, mTextChangeColor,\r\n\t\t\t\t(int) (mTextStartX + (1 - mProgress) * mTextWidth), mTextStartX\r\n\t\t\t\t\t\t+ mTextWidth);\r\n\t}\r\n\r\n\tprivate void drawOriginRight(Canvas canvas, int r) {\r\n\t\tdrawText_h(canvas, mTextOriginColor, mTextStartX,\r\n\t\t\t\t(int) (mTextStartX + (1 - mProgress) * mTextWidth));\r\n\t}\r\n\r\n\tprivate void drawChangeTop(Canvas canvas, int r) {\r\n\t\tdrawText_v(canvas, mTextChangeColor, mTextStartY,\r\n\t\t\t\t(int) (mTextStartY + mProgress * mTextHeight));\r\n\t}\r\n\r\n\tprivate void drawOriginTop(Canvas canvas, int r) {\r\n\t\tdrawText_v(canvas, mTextOriginColor, (int) (mTextStartY + mProgress\r\n\t\t\t\t* mTextHeight), mTextStartY + mTextHeight);\r\n\t}\r\n\r\n\tprivate void drawChangeBottom(Canvas canvas, int t) {\r\n\t\tdrawText_v(canvas, mTextChangeColor,\r\n\t\t\t\t(int) (mTextStartY + (1 - mProgress) * mTextHeight),\r\n\t\t\t\tmTextStartY + mTextHeight);\r\n\t}\r\n\r\n\tprivate void drawOriginBottom(Canvas canvas, int t) {\r\n\t\tdrawText_v(canvas, mTextOriginColor, mTextStartY,\r\n\t\t\t\t(int) (mTextStartY + (1 - mProgress) * mTextHeight));\r\n\t}\r\n\r\n\tpublic float getProgress() {\r\n\t\treturn mProgress;\r\n\t}\r\n\r\n\tpublic void setProgress(float progress) {\r\n\t\tthis.mProgress = progress;\r\n\t\tinvalidate();\r\n\t}\r\n\r\n\tpublic int getTextSize() {\r\n\t\treturn mTextSize;\r\n\t}\r\n\r\n\tpublic void setTextSize(int mTextSize) {\r\n\t\tthis.mTextSize = mTextSize;\r\n\t\tmPaint.setTextSize(mTextSize);\r\n\t\trequestLayout();\r\n\t\tinvalidate();\r\n\t}\r\n\t\r\n\tpublic void setText(String text) {\r\n\t\tthis.mText = text;\r\n\t\trequestLayout();\r\n\t\tinvalidate();\r\n\t}\r\n\r\n\tpublic int getTextOriginColor() {\r\n\t\treturn mTextOriginColor;\r\n\t}\r\n\r\n\tpublic void setTextOriginColor(int mTextOriginColor) {\r\n\t\tthis.mTextOriginColor = mTextOriginColor;\r\n\t\tinvalidate();\r\n\t}\r\n\r\n\tpublic int getTextChangeColor() {\r\n\t\treturn mTextChangeColor;\r\n\t}\r\n\r\n\tpublic void setTextChangeColor(int mTextChangeColor) {\r\n\t\tthis.mTextChangeColor = mTextChangeColor;\r\n\t\tinvalidate();\r\n\t}\r\n\r\n\tprivate int dp2px(float dpVal) {\r\n\t\treturn (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,\r\n\t\t\t\tdpVal, getResources().getDisplayMetrics());\r\n\t}\r\n\r\n\tprivate int sp2px(float dpVal) {\r\n\t\treturn (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,\r\n\t\t\t\tdpVal, getResources().getDisplayMetrics());\r\n\t}\r\n\r\n\tprivate static final String KEY_STATE_PROGRESS = \"key_progress\";\r\n\tprivate static final String KEY_DEFAULT_STATE = \"key_default_state\";\r\n\r\n\t@Override\r\n\tprotected Parcelable onSaveInstanceState() {\r\n\t\tBundle bundle = new Bundle();\r\n\t\tbundle.putFloat(KEY_STATE_PROGRESS, mProgress);\r\n\t\tbundle.putParcelable(KEY_DEFAULT_STATE, super.onSaveInstanceState());\r\n\t\treturn bundle;\r\n\t}\r\n\r\n\t@Override\r\n\tprotected void onRestoreInstanceState(Parcelable state) {\r\n\r\n\t\tif (state instanceof Bundle) {\r\n\t\t\tBundle bundle = (Bundle) state;\r\n\t\t\tmProgress = bundle.getFloat(KEY_STATE_PROGRESS);\r\n\t\t\tsuper.onRestoreInstanceState(bundle\r\n\t\t\t\t\t.getParcelable(KEY_DEFAULT_STATE));\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tsuper.onRestoreInstanceState(state);\r\n\t}\r\n}\r\n"
  },
  {
    "path": "sample_ColorTrackeView/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"src\" path=\"gen\"/>\n\t<classpathentry kind=\"con\" path=\"com.android.ide.eclipse.adt.ANDROID_FRAMEWORK\"/>\n\t<classpathentry exported=\"true\" kind=\"con\" path=\"com.android.ide.eclipse.adt.LIBRARIES\"/>\n\t<classpathentry exported=\"true\" kind=\"con\" path=\"com.android.ide.eclipse.adt.DEPENDENCIES\"/>\n\t<classpathentry exported=\"true\" kind=\"lib\" path=\"libs/android-support-v4.jar\"/>\n\t<classpathentry kind=\"output\" path=\"bin/classes\"/>\n</classpath>\n"
  },
  {
    "path": "sample_ColorTrackeView/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>sample_ColorTrackeView</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t\t<buildCommand>\n\t\t\t<name>com.android.ide.eclipse.adt.ApkBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>com.android.ide.eclipse.adt.AndroidNature</nature>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "sample_ColorTrackeView/.settings/org.eclipse.jdt.core.prefs",
    "content": "eclipse.preferences.version=1\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\norg.eclipse.jdt.core.compiler.compliance=1.6\norg.eclipse.jdt.core.compiler.source=1.6\n"
  },
  {
    "path": "sample_ColorTrackeView/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.zhy.viewpagerIndicator\"\n    android:versionCode=\"1\"\n    android:versionName=\"1.0\" >\n\n    <uses-sdk\n        android:minSdkVersion=\"8\"\n        android:targetSdkVersion=\"19\" />\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@drawable/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:theme=\"@style/AppTheme\" >\n        <activity\n            android:name=\"com.zhy.viewpagerIndicator.HomeActivity\"\n            android:label=\"@string/app_name\" >\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n        <activity android:name=\".SimpleUseActivity\" >\n        </activity>\n        <activity android:name=\".ViewPagerUseActivity\" >\n        </activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "sample_ColorTrackeView/proguard-project.txt",
    "content": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in that file.\n#\n# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in ${sdk.dir}/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the ProGuard\n# include property in project.properties.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "sample_ColorTrackeView/project.properties",
    "content": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# This file must be checked in Version Control Systems.\n#\n# To customize properties used by the Ant build system edit\n# \"ant.properties\", and override values to adapt the script to your\n# project structure.\n#\n# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):\n#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt\n\n# Project target.\ntarget=android-17\nandroid.library.reference.1=../library_ColorTrackView\n"
  },
  {
    "path": "sample_ColorTrackeView/res/layout/activity_simple_main.xml",
    "content": "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n    xmlns:tools=\"http://schemas.android.com/tools\"\r\n    xmlns:zhy=\"http://schemas.android.com/apk/res-auto\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\" >\r\n\r\n    <com.zhy.view.ColorTrackView\r\n        android:id=\"@+id/id_changeTextColorView\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_centerInParent=\"true\"\r\n        android:background=\"#44ff0000\"\r\n        android:padding=\"10dp\"\r\n        zhy:progress=\"0\"\r\n        zhy:text=\"张鸿洋\"\r\n        zhy:text_change_color=\"#ffff0000\"\r\n        zhy:text_origin_color=\"#ff000000\"\r\n        zhy:text_size=\"60sp\" />\r\n\r\n    <LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_alignParentBottom=\"true\"\r\n        android:gravity=\"center\"\r\n        android:orientation=\"horizontal\" >\r\n\r\n        <Button\r\n            android:id=\"@+id/id_left\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:onClick=\"startLeftChange\"\r\n            android:text=\"StartLeft\" />\r\n\r\n        <Button\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_toRightOf=\"@id/id_left\"\r\n            android:onClick=\"startRightChange\"\r\n            android:text=\"StartRight\" />\r\n    </LinearLayout>\r\n\r\n</RelativeLayout>"
  },
  {
    "path": "sample_ColorTrackeView/res/layout/activity_vp_main.xml",
    "content": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:zhy=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\" >\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"50dp\"\n        android:orientation=\"horizontal\" >\n\n        <com.zhy.view.ColorTrackView\n            android:id=\"@+id/id_tab_01\"\n            android:layout_width=\"0dp\"\n            android:layout_height=\"match_parent\"\n            android:layout_weight=\"1\"\n            zhy:progress=\"1\"\n            zhy:text=\"简介\"\n            zhy:text_change_color=\"#ffff0000\"\n            zhy:text_origin_color=\"#ff000000\"\n            zhy:text_size=\"18sp\" />\n\n        <com.zhy.view.ColorTrackView\n            android:id=\"@+id/id_tab_02\"\n            android:layout_width=\"0dp\"\n            android:layout_height=\"match_parent\"\n            android:layout_weight=\"1\"\n            zhy:text=\"评价\"\n            zhy:text_change_color=\"#ffff0000\"\n            zhy:text_origin_color=\"#ff000000\"\n            zhy:text_size=\"18sp\" />\n\n        <com.zhy.view.ColorTrackView\n            android:id=\"@+id/id_tab_03\"\n            android:layout_width=\"0dp\"\n            android:layout_height=\"match_parent\"\n            android:layout_weight=\"1\"\n            zhy:text=\"相关\"\n            zhy:text_change_color=\"#ffff0000\"\n            zhy:text_origin_color=\"#ff000000\"\n            zhy:text_size=\"18sp\" />\n\n        \n    </LinearLayout>\n\n    <android.support.v4.view.ViewPager\n        android:id=\"@+id/id_viewpager\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\" >\n    </android.support.v4.view.ViewPager>\n\n</LinearLayout>"
  },
  {
    "path": "sample_ColorTrackeView/res/menu/main.xml",
    "content": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n\n    <item\n        android:id=\"@+id/action_settings\"\n        android:orderInCategory=\"100\"\n        android:showAsAction=\"never\"\n        android:title=\"@string/action_settings\"/>\n\n</menu>\n"
  },
  {
    "path": "sample_ColorTrackeView/res/values/dimens.xml",
    "content": "<resources>\n\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n\n</resources>\n"
  },
  {
    "path": "sample_ColorTrackeView/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">sample_viewpagerindicator</string>\n    <string name=\"action_settings\">Settings</string>\n    <string name=\"hello_world\">Hello world!</string>\n\n</resources>\n"
  },
  {
    "path": "sample_ColorTrackeView/res/values/styles.xml",
    "content": "<resources>\n\n    <!--\n        Base application theme, dependent on API level. This theme is replaced\n        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.\n    -->\n    <style name=\"AppBaseTheme\" parent=\"android:Theme.Light\">\n        <!--\n            Theme customizations available in newer API levels can go in\n            res/values-vXX/styles.xml, while customizations related to\n            backward-compatibility can go here.\n        -->\n    </style>\n\n    <!-- Application theme. -->\n    <style name=\"AppTheme\" parent=\"AppBaseTheme\">\n        <!-- All customizations that are NOT specific to a particular API-level can go here. -->\n    </style>\n\n</resources>\n"
  },
  {
    "path": "sample_ColorTrackeView/res/values-sw600dp/dimens.xml",
    "content": "<resources>\n\n    <!--\n         Customize dimensions originally defined in res/values/dimens.xml (such as\n         screen margins) for sw600dp devices (e.g. 7\" tablets) here.\n    -->\n\n</resources>\n"
  },
  {
    "path": "sample_ColorTrackeView/res/values-sw720dp-land/dimens.xml",
    "content": "<resources>\n\n    <!--\n         Customize dimensions originally defined in res/values/dimens.xml (such as\n         screen margins) for sw720dp devices (e.g. 10\" tablets) in landscape here.\n    -->\n    <dimen name=\"activity_horizontal_margin\">128dp</dimen>\n\n</resources>\n"
  },
  {
    "path": "sample_ColorTrackeView/res/values-v11/styles.xml",
    "content": "<resources>\n\n    <!--\n        Base application theme for API 11+. This theme completely replaces\n        AppBaseTheme from res/values/styles.xml on API 11+ devices.\n    -->\n    <style name=\"AppBaseTheme\" parent=\"android:Theme.Holo.Light\">\n        <!-- API 11 theme customizations can go here. -->\n    </style>\n\n</resources>\n"
  },
  {
    "path": "sample_ColorTrackeView/res/values-v14/styles.xml",
    "content": "<resources>\n\n    <!--\n        Base application theme for API 14+. This theme completely replaces\n        AppBaseTheme from BOTH res/values/styles.xml and\n        res/values-v11/styles.xml on API 14+ devices.\n    -->\n    <style name=\"AppBaseTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\">\n        <!-- API 14 theme customizations can go here. -->\n    </style>\n\n</resources>\n"
  },
  {
    "path": "sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/HomeActivity.java",
    "content": "package com.zhy.viewpagerIndicator;\n\nimport android.app.ListActivity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.view.View;\nimport android.view.ViewPropertyAnimator;\nimport android.widget.ArrayAdapter;\nimport android.widget.ListView;\n\npublic class HomeActivity extends ListActivity\n{\n\tprivate String[] mStrs = new String[] { \"Simple Use\", \"ViewPager Use\" };\n\n\t@Override\n\tprotected void onCreate(Bundle savedInstanceState)\n\t{\n\t\tsuper.onCreate(savedInstanceState);\n\n\t\tgetListView().setAdapter(\n\t\t\t\tnew ArrayAdapter<String>(this,\n\t\t\t\t\t\tandroid.R.layout.simple_list_item_1, mStrs));\n\t}\n\n\t@Override\n\tprotected void onListItemClick(ListView l, View v, int position, long id)\n\t{\n\t\tIntent intent = null;\n\t\tswitch (position)\n\t\t{\n\t\tcase 0:\n\t\t\tintent = new Intent(this,SimpleUseActivity.class);\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tintent = new Intent(this,ViewPagerUseActivity.class);\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tif(intent != null ) startActivity(intent);\n\t}\n\n}\n"
  },
  {
    "path": "sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/SimpleUseActivity.java",
    "content": "package com.zhy.viewpagerIndicator;\r\n\r\nimport android.animation.ObjectAnimator;\r\nimport android.annotation.SuppressLint;\r\nimport android.app.Activity;\r\nimport android.os.Bundle;\r\nimport android.view.View;\r\n\r\nimport com.zhy.view.ColorTrackView;\r\n\r\npublic class SimpleUseActivity extends Activity\r\n{\r\n\r\n\tColorTrackView mView;\r\n\r\n\t@Override\r\n\tprotected void onCreate(Bundle savedInstanceState)\r\n\t{\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.activity_simple_main);\r\n\t\tmView = (ColorTrackView) findViewById(R.id.id_changeTextColorView);\r\n\t\t\r\n\r\n\t}\r\n\r\n\t@SuppressLint(\"NewApi\")\r\n\tpublic void startLeftChange(View view)\r\n\t{\r\n\t\tmView.setDirection(0);\r\n\t\tObjectAnimator.ofFloat(mView, \"progress\", 0, 1).setDuration(2000)\r\n\t\t\t\t.start();\r\n\t}\r\n\r\n\t@SuppressLint(\"NewApi\")\r\n\tpublic void startRightChange(View view)\r\n\t{\r\n\t\tmView.setDirection(1);\r\n\t\tObjectAnimator.ofFloat(mView, \"progress\", 0, 1).setDuration(2000)\r\n\t\t\t\t.start();\r\n\t}\r\n\r\n}\r\n"
  },
  {
    "path": "sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/TabFragment.java",
    "content": "package com.zhy.viewpagerIndicator;\r\n\r\nimport java.util.Random;\r\n\r\nimport android.graphics.Color;\r\nimport android.os.Bundle;\r\nimport android.support.v4.app.Fragment;\r\nimport android.view.Gravity;\r\nimport android.view.LayoutInflater;\r\nimport android.view.View;\r\nimport android.view.ViewGroup;\r\nimport android.widget.TextView;\r\n\r\npublic class TabFragment extends Fragment\r\n{\r\n\tpublic static final String TITLE = \"title\";\r\n\tprivate String mTitle = \"Defaut Value\";\r\n\r\n\t@Override\r\n\tpublic void onCreate(Bundle savedInstanceState)\r\n\t{\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tif (getArguments() != null)\r\n\t\t{\r\n\t\t\tmTitle = getArguments().getString(TITLE);\r\n\t\t}\r\n\t}\r\n\r\n\t@Override\r\n\tpublic View onCreateView(LayoutInflater inflater, ViewGroup container,\r\n\t\t\tBundle savedInstanceState)\r\n\t{\r\n\t\tTextView tv = new TextView(getActivity());\r\n\t\ttv.setTextSize(60);\r\n\t\tRandom r = new Random();\r\n\t\ttv.setBackgroundColor(Color.argb(r.nextInt(120), r.nextInt(255),\r\n\t\t\t\tr.nextInt(255), r.nextInt(255)));\r\n\t\ttv.setText(mTitle);\r\n\t\ttv.setGravity(Gravity.CENTER);\r\n\t\treturn tv;\r\n\r\n\t}\r\n\r\n\tpublic static TabFragment newInstance(String title)\r\n\t{\r\n\t\tTabFragment tabFragment = new TabFragment();\r\n\t\tBundle bundle = new Bundle();\r\n\t\tbundle.putString(TITLE, title);\r\n\t\ttabFragment.setArguments(bundle);\r\n\t\treturn tabFragment;\r\n\t}\r\n\r\n}\r\n"
  },
  {
    "path": "sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/ViewPagerUseActivity.java",
    "content": "package com.zhy.viewpagerIndicator;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport android.os.Bundle;\r\nimport android.support.v4.app.Fragment;\r\nimport android.support.v4.app.FragmentActivity;\r\nimport android.support.v4.app.FragmentPagerAdapter;\r\nimport android.support.v4.view.ViewPager;\r\nimport android.support.v4.view.ViewPager.OnPageChangeListener;\r\nimport android.util.Log;\r\n\r\nimport com.zhy.view.ColorTrackView;\r\n\r\npublic class ViewPagerUseActivity extends FragmentActivity\r\n{\r\n\tprivate String[] mTitles = new String[] { \"简介\", \"评价\", \"相关\" };\r\n\tprivate ViewPager mViewPager;\r\n\tprivate FragmentPagerAdapter mAdapter;\r\n\tprivate TabFragment[] mFragments = new TabFragment[mTitles.length];\r\n\tprivate List<ColorTrackView> mTabs = new ArrayList<ColorTrackView>();\r\n\r\n\t@Override\r\n\tprotected void onCreate(Bundle savedInstanceState)\r\n\t{\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.activity_vp_main);\r\n\r\n\t\tinitViews();\r\n\t\tinitDatas();\r\n\t\tinitEvents();\r\n\t}\r\n\r\n\tprivate void initEvents()\r\n\t{\r\n\t\tmViewPager.setOnPageChangeListener(new OnPageChangeListener()\r\n\t\t{\r\n\t\t\t@Override\r\n\t\t\tpublic void onPageSelected(int position)\r\n\t\t\t{\r\n\t\t\t}\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic void onPageScrolled(int position, float positionOffset,\r\n\t\t\t\t\tint positionOffsetPixels)\r\n\t\t\t{\r\n\t\t\t\tif (positionOffset > 0)  \r\n\t\t        {  \r\n\t\t\t\t\tColorTrackView left = mTabs.get(position);  \r\n\t\t\t\t\tColorTrackView right = mTabs.get(position + 1);  \r\n\t\t\t\t\t\r\n\t\t\t\t\tleft.setDirection(1);\r\n\t\t\t\t\tright.setDirection(0);\r\n\t\t\t\t\tLog.e(\"TAG\", positionOffset+\"\");\r\n\t\t            left.setProgress( 1-positionOffset);  \r\n\t\t            right.setProgress(positionOffset);  \r\n\t\t        }  \r\n\t\t\t}\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic void onPageScrollStateChanged(int state)\r\n\t\t\t{\r\n\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t}\r\n\r\n\tprivate void initDatas()\r\n\t{\r\n\r\n\t\tfor (int i = 0; i < mTitles.length; i++)\r\n\t\t{\r\n\t\t\tmFragments[i] = (TabFragment) TabFragment.newInstance(mTitles[i]);\r\n\t\t}\r\n\r\n\t\tmAdapter = new FragmentPagerAdapter(getSupportFragmentManager())\r\n\t\t{\r\n\t\t\t@Override\r\n\t\t\tpublic int getCount()\r\n\t\t\t{\r\n\t\t\t\treturn mTitles.length;\r\n\t\t\t}\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic Fragment getItem(int position)\r\n\t\t\t{\r\n\t\t\t\treturn mFragments[position];\r\n\t\t\t}\r\n\r\n\t\t};\r\n\r\n\t\tmViewPager.setAdapter(mAdapter);\r\n\t\tmViewPager.setCurrentItem(0);\r\n\t}\r\n\r\n\tprivate void initViews()\r\n\t{\r\n\t\tmViewPager = (ViewPager) findViewById(R.id.id_viewpager);\r\n\t\t\r\n\t\tmTabs.add((ColorTrackView) findViewById(R.id.id_tab_01));\r\n\t\tmTabs.add((ColorTrackView) findViewById(R.id.id_tab_02));\r\n\t\tmTabs.add((ColorTrackView) findViewById(R.id.id_tab_03));\r\n\t}\r\n\r\n}\r\n"
  }
]