master d8d8bfcd4098 cached
41 files
43.4 KB
11.9k tokens
50 symbols
1 requests
Download .txt
Repository: hongyangAndroid/ColorTrackView
Branch: master
Commit: d8d8bfcd4098
Files: 41
Total size: 43.4 KB

Directory structure:
gitextract_tbqekwy9/

├── .gitignore
├── LICENSE
├── README.md
├── library_ColorTrackView/
│   ├── .classpath
│   ├── .project
│   ├── .settings/
│   │   ├── org.eclipse.core.resources.prefs
│   │   └── org.eclipse.jdt.core.prefs
│   ├── AndroidManifest.xml
│   ├── proguard-project.txt
│   ├── project.properties
│   ├── res/
│   │   ├── menu/
│   │   │   └── main.xml
│   │   ├── values/
│   │   │   ├── attr.xml
│   │   │   ├── dimens.xml
│   │   │   ├── strings.xml
│   │   │   └── styles.xml
│   │   ├── values-sw600dp/
│   │   │   └── dimens.xml
│   │   ├── values-sw720dp-land/
│   │   │   └── dimens.xml
│   │   ├── values-v11/
│   │   │   └── styles.xml
│   │   └── values-v14/
│   │       └── styles.xml
│   └── src/
│       └── com/
│           └── zhy/
│               └── view/
│                   └── ColorTrackView.java
└── sample_ColorTrackeView/
    ├── .classpath
    ├── .project
    ├── .settings/
    │   └── org.eclipse.jdt.core.prefs
    ├── AndroidManifest.xml
    ├── libs/
    │   └── android-support-v4.jar
    ├── proguard-project.txt
    ├── project.properties
    ├── res/
    │   ├── layout/
    │   │   ├── activity_simple_main.xml
    │   │   └── activity_vp_main.xml
    │   ├── menu/
    │   │   └── main.xml
    │   ├── values/
    │   │   ├── dimens.xml
    │   │   ├── strings.xml
    │   │   └── styles.xml
    │   ├── values-sw600dp/
    │   │   └── dimens.xml
    │   ├── values-sw720dp-land/
    │   │   └── dimens.xml
    │   ├── values-v11/
    │   │   └── styles.xml
    │   └── values-v14/
    │       └── styles.xml
    └── src/
        └── com/
            └── zhy/
                └── viewpagerIndicator/
                    ├── HomeActivity.java
                    ├── SimpleUseActivity.java
                    ├── TabFragment.java
                    └── ViewPagerUseActivity.java

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log


================================================
FILE: LICENSE
================================================
Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   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.



================================================
FILE: README.md
================================================
# Android-ColorTrackView
字体或者图片可以逐渐染色和逐渐褪色的动画效果

# 使用

```xml
 <com.zhy.view.ColorTrackView
        android:id="@+id/id_changeTextColorView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_centerVertical="true"
        android:padding="20dp"
        android:background="#44ff0000"
        android:gravity="center_vertical"
        zhy:progress="0"
        zhy:direction="left"
        zhy:text="张鸿洋"
        zhy:text_change_color="#ffff0000"
        zhy:text_origin_color="#ff000000"
        zhy:text_size="60sp" />
```

注:zhy为命名空间,xmlns:zhy="http://schemas.android.com/apk/res-auto",可自由修改。

* `progress`  [0.0f , 1.0f]
* `text` 绘制的文本
* `text_change_color`目标颜色
* `text_origin_color`原始颜色
* `text_size`字体大小
* `direction `方向,枚举类型,支持:left,right,top,bottom

# 效果图

## 简单使用
![](sample_ColorTrackeView/sc.gif)

## 结合ViewPager
![](sample_ColorTrackeView/changecolortvdemo.gif)


# 关于我
[我的博客地址](http://blog.csdn.net/lmj623565791)




================================================
FILE: library_ColorTrackView/.classpath
================================================
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
	<classpathentry kind="output" path="bin/classes"/>
</classpath>


================================================
FILE: library_ColorTrackView/.project
================================================
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>library_ColorTrackView</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
		<nature>org.eclipse.jdt.core.javanature</nature>
	</natures>
</projectDescription>


================================================
FILE: library_ColorTrackView/.settings/org.eclipse.core.resources.prefs
================================================
eclipse.preferences.version=1
encoding/<project>=UTF-8


================================================
FILE: library_ColorTrackView/.settings/org.eclipse.jdt.core.prefs
================================================
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6


================================================
FILE: library_ColorTrackView/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zhy.sample_color_change_text"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.zhy.sample_color_change_text.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


================================================
FILE: library_ColorTrackView/proguard-project.txt
================================================
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}


================================================
FILE: library_ColorTrackView/project.properties
================================================
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
android.library=true


================================================
FILE: library_ColorTrackView/res/menu/main.xml
================================================
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/action_settings"/>

</menu>


================================================
FILE: library_ColorTrackView/res/values/attr.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <attr name="text" format="string" />
    <attr name="text_size" format="dimension" />
    <attr name="text_origin_color" format="color|reference" />
    <attr name="text_change_color" format="color|reference" />
    <attr name="progress" format="float" />
    <attr name="direction">
        <enum name="left" value="0" />
        <enum name="right" value="1" />
        <enum name="top" value="2" />
        <enum name="bottom" value="3" />
    </attr>

    <declare-styleable name="ColorTrackView">
        <attr name="text" />
        <attr name="text_size" />
        <attr name="text_origin_color" />
        <attr name="text_change_color" />
        <attr name="progress" />
        <attr name="direction" />
    </declare-styleable>

</resources>

================================================
FILE: library_ColorTrackView/res/values/dimens.xml
================================================
<resources>

    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>

</resources>


================================================
FILE: library_ColorTrackView/res/values/strings.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">sample_color_change_text</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string>

</resources>


================================================
FILE: library_ColorTrackView/res/values/styles.xml
================================================
<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>


================================================
FILE: library_ColorTrackView/res/values-sw600dp/dimens.xml
================================================
<resources>

    <!--
         Customize dimensions originally defined in res/values/dimens.xml (such as
         screen margins) for sw600dp devices (e.g. 7" tablets) here.
    -->

</resources>


================================================
FILE: library_ColorTrackView/res/values-sw720dp-land/dimens.xml
================================================
<resources>

    <!--
         Customize dimensions originally defined in res/values/dimens.xml (such as
         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
    -->
    <dimen name="activity_horizontal_margin">128dp</dimen>

</resources>


================================================
FILE: library_ColorTrackView/res/values-v11/styles.xml
================================================
<resources>

    <!--
        Base application theme for API 11+. This theme completely replaces
        AppBaseTheme from res/values/styles.xml on API 11+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <!-- API 11 theme customizations can go here. -->
    </style>

</resources>


================================================
FILE: library_ColorTrackView/res/values-v14/styles.xml
================================================
<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
    </style>

</resources>


================================================
FILE: library_ColorTrackView/src/com/zhy/view/ColorTrackView.java
================================================
package com.zhy.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.FontMetrics;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;

import com.zhy.sample_color_change_text.R;

/**
 * 
 * @author zhy
 * 
 */
public class ColorTrackView extends View {

	private int mTextStartX;
	private int mTextStartY;

	public enum Direction {
		LEFT, RIGHT, TOP, BOTTOM;
	}

	private int mDirection = DIRECTION_LEFT;

	private static final int DIRECTION_LEFT = 0;
	private static final int DIRECTION_RIGHT = 1;
	private static final int DIRECTION_TOP = 2;
	private static final int DIRECTION_BOTTOM = 3;

	public void setDirection(int direction) {
		mDirection = direction;
	}

	private String mText = "张鸿洋";
	private Paint mPaint;
	private int mTextSize = sp2px(30);

	private int mTextOriginColor = 0xff000000;
	private int mTextChangeColor = 0xffff0000;

	private Rect mTextBound = new Rect();
	private int mTextWidth;
	private int mTextHeight;

	private float mProgress;

	public ColorTrackView(Context context) {
		super(context, null);
	}

	public ColorTrackView(Context context, AttributeSet attrs) {
		super(context, attrs);

		mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

		TypedArray ta = context.obtainStyledAttributes(attrs,
				R.styleable.ColorTrackView);
		mText = ta.getString(R.styleable.ColorTrackView_text);
		mTextSize = ta.getDimensionPixelSize(
				R.styleable.ColorTrackView_text_size, mTextSize);
		mTextOriginColor = ta.getColor(
				R.styleable.ColorTrackView_text_origin_color, mTextOriginColor);
		mTextChangeColor = ta.getColor(
				R.styleable.ColorTrackView_text_change_color, mTextChangeColor);
		mProgress = ta.getFloat(R.styleable.ColorTrackView_progress, 0);

		mDirection = ta
				.getInt(R.styleable.ColorTrackView_direction, mDirection);

		ta.recycle();

		mPaint.setTextSize(mTextSize);

	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

		measureText();

		int width = measureWidth(widthMeasureSpec);
		int height = measureHeight(heightMeasureSpec);
		setMeasuredDimension(width, height);

		mTextStartX = getMeasuredWidth() / 2 - mTextWidth / 2;
		mTextStartY = getMeasuredHeight() / 2 - mTextHeight / 2;
	}

	private int measureHeight(int measureSpec) {
		int mode = MeasureSpec.getMode(measureSpec);
		int val = MeasureSpec.getSize(measureSpec);
		int result = 0;
		switch (mode) {
		case MeasureSpec.EXACTLY:
			result = val;
			break;
		case MeasureSpec.AT_MOST:
		case MeasureSpec.UNSPECIFIED:
			result = mTextBound.height();
			result += getPaddingTop() + getPaddingBottom();
			break;
		}
		result = mode == MeasureSpec.AT_MOST ? Math.min(result, val) : result;
		return result;
	}

	private int measureWidth(int measureSpec) {
		int mode = MeasureSpec.getMode(measureSpec);
		int val = MeasureSpec.getSize(measureSpec);
		int result = 0;
		switch (mode) {
		case MeasureSpec.EXACTLY:
			result = val;
			break;
		case MeasureSpec.AT_MOST:
		case MeasureSpec.UNSPECIFIED:
			// result = mTextBound.width();
			result = mTextWidth;
			result += getPaddingLeft() + getPaddingRight();
			break;
		}
		result = mode == MeasureSpec.AT_MOST ? Math.min(result, val) : result;
		return result;
	}

	private void measureText() {
		mTextWidth = (int) mPaint.measureText(mText);
		FontMetrics fm = mPaint.getFontMetrics();
		mTextHeight = (int) Math.ceil(fm.descent - fm.top);

		mPaint.getTextBounds(mText, 0, mText.length(), mTextBound);
		mTextHeight = mTextBound.height();
	}

	public void reverseColor() {
		int tmp = mTextOriginColor;
		mTextOriginColor = mTextChangeColor;
		mTextChangeColor = tmp;
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);

		int r = (int) (mProgress * mTextWidth + mTextStartX);
		int t = (int) (mProgress * mTextHeight + mTextStartY);

		if (mDirection == DIRECTION_LEFT) {
			drawChangeLeft(canvas, r);
			drawOriginLeft(canvas, r);
		} else if (mDirection == DIRECTION_RIGHT) {
			drawOriginRight(canvas, r);
			drawChangeRight(canvas, r);
		} else if (mDirection == DIRECTION_TOP) {
			drawOriginTop(canvas, t);
			drawChangeTop(canvas, t);
		} else {
			drawOriginBottom(canvas, t);
			drawChangeBottom(canvas, t);
		}

	}

	private boolean debug = false;

	private void drawText_h(Canvas canvas, int color, int startX, int endX) {
		mPaint.setColor(color);
		if (debug) {
			mPaint.setStyle(Style.STROKE);
			canvas.drawRect(startX, 0, endX, getMeasuredHeight(), mPaint);
		}
		canvas.save(Canvas.CLIP_SAVE_FLAG);
		canvas.clipRect(startX, 0, endX, getMeasuredHeight());// left, top,
																// right, bottom
		canvas.drawText(mText, mTextStartX,
				getMeasuredHeight() / 2
						- ((mPaint.descent() + mPaint.ascent()) / 2), mPaint);
		canvas.restore();
	}

	private void drawText_v(Canvas canvas, int color, int startY, int endY) {
		mPaint.setColor(color);
		if (debug) {
			mPaint.setStyle(Style.STROKE);
			canvas.drawRect(0, startY, getMeasuredWidth(), endY, mPaint);
		}

		canvas.save(Canvas.CLIP_SAVE_FLAG);
		canvas.clipRect(0, startY, getMeasuredWidth(), endY);// left, top,
		canvas.drawText(mText, mTextStartX,
				getMeasuredHeight() / 2
						- ((mPaint.descent() + mPaint.ascent()) / 2), mPaint);
		canvas.restore();
	}

	private void drawChangeLeft(Canvas canvas, int r) {
		drawText_h(canvas, mTextChangeColor, mTextStartX,
				(int) (mTextStartX + mProgress * mTextWidth));
	}

	private void drawOriginLeft(Canvas canvas, int r) {
		drawText_h(canvas, mTextOriginColor, (int) (mTextStartX + mProgress
				* mTextWidth), mTextStartX + mTextWidth);
	}

	private void drawChangeRight(Canvas canvas, int r) {
		drawText_h(canvas, mTextChangeColor,
				(int) (mTextStartX + (1 - mProgress) * mTextWidth), mTextStartX
						+ mTextWidth);
	}

	private void drawOriginRight(Canvas canvas, int r) {
		drawText_h(canvas, mTextOriginColor, mTextStartX,
				(int) (mTextStartX + (1 - mProgress) * mTextWidth));
	}

	private void drawChangeTop(Canvas canvas, int r) {
		drawText_v(canvas, mTextChangeColor, mTextStartY,
				(int) (mTextStartY + mProgress * mTextHeight));
	}

	private void drawOriginTop(Canvas canvas, int r) {
		drawText_v(canvas, mTextOriginColor, (int) (mTextStartY + mProgress
				* mTextHeight), mTextStartY + mTextHeight);
	}

	private void drawChangeBottom(Canvas canvas, int t) {
		drawText_v(canvas, mTextChangeColor,
				(int) (mTextStartY + (1 - mProgress) * mTextHeight),
				mTextStartY + mTextHeight);
	}

	private void drawOriginBottom(Canvas canvas, int t) {
		drawText_v(canvas, mTextOriginColor, mTextStartY,
				(int) (mTextStartY + (1 - mProgress) * mTextHeight));
	}

	public float getProgress() {
		return mProgress;
	}

	public void setProgress(float progress) {
		this.mProgress = progress;
		invalidate();
	}

	public int getTextSize() {
		return mTextSize;
	}

	public void setTextSize(int mTextSize) {
		this.mTextSize = mTextSize;
		mPaint.setTextSize(mTextSize);
		requestLayout();
		invalidate();
	}
	
	public void setText(String text) {
		this.mText = text;
		requestLayout();
		invalidate();
	}

	public int getTextOriginColor() {
		return mTextOriginColor;
	}

	public void setTextOriginColor(int mTextOriginColor) {
		this.mTextOriginColor = mTextOriginColor;
		invalidate();
	}

	public int getTextChangeColor() {
		return mTextChangeColor;
	}

	public void setTextChangeColor(int mTextChangeColor) {
		this.mTextChangeColor = mTextChangeColor;
		invalidate();
	}

	private int dp2px(float dpVal) {
		return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
				dpVal, getResources().getDisplayMetrics());
	}

	private int sp2px(float dpVal) {
		return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
				dpVal, getResources().getDisplayMetrics());
	}

	private static final String KEY_STATE_PROGRESS = "key_progress";
	private static final String KEY_DEFAULT_STATE = "key_default_state";

	@Override
	protected Parcelable onSaveInstanceState() {
		Bundle bundle = new Bundle();
		bundle.putFloat(KEY_STATE_PROGRESS, mProgress);
		bundle.putParcelable(KEY_DEFAULT_STATE, super.onSaveInstanceState());
		return bundle;
	}

	@Override
	protected void onRestoreInstanceState(Parcelable state) {

		if (state instanceof Bundle) {
			Bundle bundle = (Bundle) state;
			mProgress = bundle.getFloat(KEY_STATE_PROGRESS);
			super.onRestoreInstanceState(bundle
					.getParcelable(KEY_DEFAULT_STATE));
			return;
		}
		super.onRestoreInstanceState(state);
	}
}


================================================
FILE: sample_ColorTrackeView/.classpath
================================================
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
	<classpathentry exported="true" kind="lib" path="libs/android-support-v4.jar"/>
	<classpathentry kind="output" path="bin/classes"/>
</classpath>


================================================
FILE: sample_ColorTrackeView/.project
================================================
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>sample_ColorTrackeView</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
		<nature>org.eclipse.jdt.core.javanature</nature>
	</natures>
</projectDescription>


================================================
FILE: sample_ColorTrackeView/.settings/org.eclipse.jdt.core.prefs
================================================
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6


================================================
FILE: sample_ColorTrackeView/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zhy.viewpagerIndicator"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.zhy.viewpagerIndicator.HomeActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SimpleUseActivity" >
        </activity>
        <activity android:name=".ViewPagerUseActivity" >
        </activity>
    </application>

</manifest>

================================================
FILE: sample_ColorTrackeView/proguard-project.txt
================================================
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}


================================================
FILE: sample_ColorTrackeView/project.properties
================================================
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
android.library.reference.1=../library_ColorTrackView


================================================
FILE: sample_ColorTrackeView/res/layout/activity_simple_main.xml
================================================
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:zhy="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.zhy.view.ColorTrackView
        android:id="@+id/id_changeTextColorView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="#44ff0000"
        android:padding="10dp"
        zhy:progress="0"
        zhy:text="张鸿洋"
        zhy:text_change_color="#ffff0000"
        zhy:text_origin_color="#ff000000"
        zhy:text_size="60sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="center"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/id_left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="startLeftChange"
            android:text="StartLeft" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/id_left"
            android:onClick="startRightChange"
            android:text="StartRight" />
    </LinearLayout>

</RelativeLayout>

================================================
FILE: sample_ColorTrackeView/res/layout/activity_vp_main.xml
================================================
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:zhy="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal" >

        <com.zhy.view.ColorTrackView
            android:id="@+id/id_tab_01"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            zhy:progress="1"
            zhy:text="简介"
            zhy:text_change_color="#ffff0000"
            zhy:text_origin_color="#ff000000"
            zhy:text_size="18sp" />

        <com.zhy.view.ColorTrackView
            android:id="@+id/id_tab_02"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            zhy:text="评价"
            zhy:text_change_color="#ffff0000"
            zhy:text_origin_color="#ff000000"
            zhy:text_size="18sp" />

        <com.zhy.view.ColorTrackView
            android:id="@+id/id_tab_03"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            zhy:text="相关"
            zhy:text_change_color="#ffff0000"
            zhy:text_origin_color="#ff000000"
            zhy:text_size="18sp" />

        
    </LinearLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/id_viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >
    </android.support.v4.view.ViewPager>

</LinearLayout>

================================================
FILE: sample_ColorTrackeView/res/menu/main.xml
================================================
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/action_settings"/>

</menu>


================================================
FILE: sample_ColorTrackeView/res/values/dimens.xml
================================================
<resources>

    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>

</resources>


================================================
FILE: sample_ColorTrackeView/res/values/strings.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">sample_viewpagerindicator</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string>

</resources>


================================================
FILE: sample_ColorTrackeView/res/values/styles.xml
================================================
<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>


================================================
FILE: sample_ColorTrackeView/res/values-sw600dp/dimens.xml
================================================
<resources>

    <!--
         Customize dimensions originally defined in res/values/dimens.xml (such as
         screen margins) for sw600dp devices (e.g. 7" tablets) here.
    -->

</resources>


================================================
FILE: sample_ColorTrackeView/res/values-sw720dp-land/dimens.xml
================================================
<resources>

    <!--
         Customize dimensions originally defined in res/values/dimens.xml (such as
         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
    -->
    <dimen name="activity_horizontal_margin">128dp</dimen>

</resources>


================================================
FILE: sample_ColorTrackeView/res/values-v11/styles.xml
================================================
<resources>

    <!--
        Base application theme for API 11+. This theme completely replaces
        AppBaseTheme from res/values/styles.xml on API 11+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <!-- API 11 theme customizations can go here. -->
    </style>

</resources>


================================================
FILE: sample_ColorTrackeView/res/values-v14/styles.xml
================================================
<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
    </style>

</resources>


================================================
FILE: sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/HomeActivity.java
================================================
package com.zhy.viewpagerIndicator;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class HomeActivity extends ListActivity
{
	private String[] mStrs = new String[] { "Simple Use", "ViewPager Use" };

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);

		getListView().setAdapter(
				new ArrayAdapter<String>(this,
						android.R.layout.simple_list_item_1, mStrs));
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id)
	{
		Intent intent = null;
		switch (position)
		{
		case 0:
			intent = new Intent(this,SimpleUseActivity.class);
			break;
		case 1:
			intent = new Intent(this,ViewPagerUseActivity.class);
			break;
		}
		
		if(intent != null ) startActivity(intent);
	}

}


================================================
FILE: sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/SimpleUseActivity.java
================================================
package com.zhy.viewpagerIndicator;

import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import com.zhy.view.ColorTrackView;

public class SimpleUseActivity extends Activity
{

	ColorTrackView mView;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_simple_main);
		mView = (ColorTrackView) findViewById(R.id.id_changeTextColorView);
		

	}

	@SuppressLint("NewApi")
	public void startLeftChange(View view)
	{
		mView.setDirection(0);
		ObjectAnimator.ofFloat(mView, "progress", 0, 1).setDuration(2000)
				.start();
	}

	@SuppressLint("NewApi")
	public void startRightChange(View view)
	{
		mView.setDirection(1);
		ObjectAnimator.ofFloat(mView, "progress", 0, 1).setDuration(2000)
				.start();
	}

}


================================================
FILE: sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/TabFragment.java
================================================
package com.zhy.viewpagerIndicator;

import java.util.Random;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class TabFragment extends Fragment
{
	public static final String TITLE = "title";
	private String mTitle = "Defaut Value";

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		if (getArguments() != null)
		{
			mTitle = getArguments().getString(TITLE);
		}
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState)
	{
		TextView tv = new TextView(getActivity());
		tv.setTextSize(60);
		Random r = new Random();
		tv.setBackgroundColor(Color.argb(r.nextInt(120), r.nextInt(255),
				r.nextInt(255), r.nextInt(255)));
		tv.setText(mTitle);
		tv.setGravity(Gravity.CENTER);
		return tv;

	}

	public static TabFragment newInstance(String title)
	{
		TabFragment tabFragment = new TabFragment();
		Bundle bundle = new Bundle();
		bundle.putString(TITLE, title);
		tabFragment.setArguments(bundle);
		return tabFragment;
	}

}


================================================
FILE: sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/ViewPagerUseActivity.java
================================================
package com.zhy.viewpagerIndicator;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;

import com.zhy.view.ColorTrackView;

public class ViewPagerUseActivity extends FragmentActivity
{
	private String[] mTitles = new String[] { "简介", "评价", "相关" };
	private ViewPager mViewPager;
	private FragmentPagerAdapter mAdapter;
	private TabFragment[] mFragments = new TabFragment[mTitles.length];
	private List<ColorTrackView> mTabs = new ArrayList<ColorTrackView>();

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_vp_main);

		initViews();
		initDatas();
		initEvents();
	}

	private void initEvents()
	{
		mViewPager.setOnPageChangeListener(new OnPageChangeListener()
		{
			@Override
			public void onPageSelected(int position)
			{
			}

			@Override
			public void onPageScrolled(int position, float positionOffset,
					int positionOffsetPixels)
			{
				if (positionOffset > 0)  
		        {  
					ColorTrackView left = mTabs.get(position);  
					ColorTrackView right = mTabs.get(position + 1);  
					
					left.setDirection(1);
					right.setDirection(0);
					Log.e("TAG", positionOffset+"");
		            left.setProgress( 1-positionOffset);  
		            right.setProgress(positionOffset);  
		        }  
			}

			@Override
			public void onPageScrollStateChanged(int state)
			{

			}
		});

	}

	private void initDatas()
	{

		for (int i = 0; i < mTitles.length; i++)
		{
			mFragments[i] = (TabFragment) TabFragment.newInstance(mTitles[i]);
		}

		mAdapter = new FragmentPagerAdapter(getSupportFragmentManager())
		{
			@Override
			public int getCount()
			{
				return mTitles.length;
			}

			@Override
			public Fragment getItem(int position)
			{
				return mFragments[position];
			}

		};

		mViewPager.setAdapter(mAdapter);
		mViewPager.setCurrentItem(0);
	}

	private void initViews()
	{
		mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
		
		mTabs.add((ColorTrackView) findViewById(R.id.id_tab_01));
		mTabs.add((ColorTrackView) findViewById(R.id.id_tab_02));
		mTabs.add((ColorTrackView) findViewById(R.id.id_tab_03));
	}

}
Download .txt
gitextract_tbqekwy9/

├── .gitignore
├── LICENSE
├── README.md
├── library_ColorTrackView/
│   ├── .classpath
│   ├── .project
│   ├── .settings/
│   │   ├── org.eclipse.core.resources.prefs
│   │   └── org.eclipse.jdt.core.prefs
│   ├── AndroidManifest.xml
│   ├── proguard-project.txt
│   ├── project.properties
│   ├── res/
│   │   ├── menu/
│   │   │   └── main.xml
│   │   ├── values/
│   │   │   ├── attr.xml
│   │   │   ├── dimens.xml
│   │   │   ├── strings.xml
│   │   │   └── styles.xml
│   │   ├── values-sw600dp/
│   │   │   └── dimens.xml
│   │   ├── values-sw720dp-land/
│   │   │   └── dimens.xml
│   │   ├── values-v11/
│   │   │   └── styles.xml
│   │   └── values-v14/
│   │       └── styles.xml
│   └── src/
│       └── com/
│           └── zhy/
│               └── view/
│                   └── ColorTrackView.java
└── sample_ColorTrackeView/
    ├── .classpath
    ├── .project
    ├── .settings/
    │   └── org.eclipse.jdt.core.prefs
    ├── AndroidManifest.xml
    ├── libs/
    │   └── android-support-v4.jar
    ├── proguard-project.txt
    ├── project.properties
    ├── res/
    │   ├── layout/
    │   │   ├── activity_simple_main.xml
    │   │   └── activity_vp_main.xml
    │   ├── menu/
    │   │   └── main.xml
    │   ├── values/
    │   │   ├── dimens.xml
    │   │   ├── strings.xml
    │   │   └── styles.xml
    │   ├── values-sw600dp/
    │   │   └── dimens.xml
    │   ├── values-sw720dp-land/
    │   │   └── dimens.xml
    │   ├── values-v11/
    │   │   └── styles.xml
    │   └── values-v14/
    │       └── styles.xml
    └── src/
        └── com/
            └── zhy/
                └── viewpagerIndicator/
                    ├── HomeActivity.java
                    ├── SimpleUseActivity.java
                    ├── TabFragment.java
                    └── ViewPagerUseActivity.java
Download .txt
SYMBOL INDEX (50 symbols across 5 files)

FILE: library_ColorTrackView/src/com/zhy/view/ColorTrackView.java
  class ColorTrackView (line 23) | public class ColorTrackView extends View {
    type Direction (line 28) | public enum Direction {
    method setDirection (line 39) | public void setDirection(int direction) {
    method ColorTrackView (line 56) | public ColorTrackView(Context context) {
    method ColorTrackView (line 60) | public ColorTrackView(Context context, AttributeSet attrs) {
    method onMeasure (line 85) | @Override
    method measureHeight (line 98) | private int measureHeight(int measureSpec) {
    method measureWidth (line 116) | private int measureWidth(int measureSpec) {
    method measureText (line 135) | private void measureText() {
    method reverseColor (line 144) | public void reverseColor() {
    method onDraw (line 150) | @Override
    method drawText_h (line 175) | private void drawText_h(Canvas canvas, int color, int startX, int endX) {
    method drawText_v (line 190) | private void drawText_v(Canvas canvas, int color, int startY, int endY) {
    method drawChangeLeft (line 205) | private void drawChangeLeft(Canvas canvas, int r) {
    method drawOriginLeft (line 210) | private void drawOriginLeft(Canvas canvas, int r) {
    method drawChangeRight (line 215) | private void drawChangeRight(Canvas canvas, int r) {
    method drawOriginRight (line 221) | private void drawOriginRight(Canvas canvas, int r) {
    method drawChangeTop (line 226) | private void drawChangeTop(Canvas canvas, int r) {
    method drawOriginTop (line 231) | private void drawOriginTop(Canvas canvas, int r) {
    method drawChangeBottom (line 236) | private void drawChangeBottom(Canvas canvas, int t) {
    method drawOriginBottom (line 242) | private void drawOriginBottom(Canvas canvas, int t) {
    method getProgress (line 247) | public float getProgress() {
    method setProgress (line 251) | public void setProgress(float progress) {
    method getTextSize (line 256) | public int getTextSize() {
    method setTextSize (line 260) | public void setTextSize(int mTextSize) {
    method setText (line 267) | public void setText(String text) {
    method getTextOriginColor (line 273) | public int getTextOriginColor() {
    method setTextOriginColor (line 277) | public void setTextOriginColor(int mTextOriginColor) {
    method getTextChangeColor (line 282) | public int getTextChangeColor() {
    method setTextChangeColor (line 286) | public void setTextChangeColor(int mTextChangeColor) {
    method dp2px (line 291) | private int dp2px(float dpVal) {
    method sp2px (line 296) | private int sp2px(float dpVal) {
    method onSaveInstanceState (line 304) | @Override
    method onRestoreInstanceState (line 312) | @Override

FILE: sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/HomeActivity.java
  class HomeActivity (line 11) | public class HomeActivity extends ListActivity
    method onCreate (line 15) | @Override
    method onListItemClick (line 25) | @Override

FILE: sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/SimpleUseActivity.java
  class SimpleUseActivity (line 11) | public class SimpleUseActivity extends Activity
    method onCreate (line 16) | @Override
    method startLeftChange (line 26) | @SuppressLint("NewApi")
    method startRightChange (line 34) | @SuppressLint("NewApi")

FILE: sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/TabFragment.java
  class TabFragment (line 14) | public class TabFragment extends Fragment
    method onCreate (line 19) | @Override
    method onCreateView (line 29) | @Override
    method newInstance (line 44) | public static TabFragment newInstance(String title)

FILE: sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/ViewPagerUseActivity.java
  class ViewPagerUseActivity (line 16) | public class ViewPagerUseActivity extends FragmentActivity
    method onCreate (line 24) | @Override
    method initEvents (line 35) | private void initEvents()
    method initDatas (line 70) | private void initDatas()
    method initViews (line 98) | private void initViews()
Condensed preview — 41 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (51K chars).
[
  {
    "path": ".gitignore",
    "chars": 290,
    "preview": "# 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\nbi"
  },
  {
    "path": "LICENSE",
    "chars": 11325,
    "preview": "Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licens"
  },
  {
    "path": "README.md",
    "chars": 1032,
    "preview": "# Android-ColorTrackView\n字体或者图片可以逐渐染色和逐渐褪色的动画效果\n\n# 使用\n\n```xml\n <com.zhy.view.ColorTrackView\n        android:id=\"@+id/id_"
  },
  {
    "path": "library_ColorTrackView/.classpath",
    "chars": 475,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<classpath>\r\n\t<classpathentry kind=\"src\" path=\"src\"/>\r\n\t<classpathentry kind=\"sr"
  },
  {
    "path": "library_ColorTrackView/.project",
    "chars": 825,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>library_ColorTrackView</name>\n\t<comment></comment>\n\t<"
  },
  {
    "path": "library_ColorTrackView/.settings/org.eclipse.core.resources.prefs",
    "chars": 55,
    "preview": "eclipse.preferences.version=1\nencoding/<project>=UTF-8\n"
  },
  {
    "path": "library_ColorTrackView/.settings/org.eclipse.jdt.core.prefs",
    "chars": 173,
    "preview": "eclipse.preferences.version=1\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\norg.eclipse.jdt.core.compiler.com"
  },
  {
    "path": "library_ColorTrackView/AndroidManifest.xml",
    "chars": 906,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n    package"
  },
  {
    "path": "library_ColorTrackView/proguard-project.txt",
    "chars": 781,
    "preview": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in t"
  },
  {
    "path": "library_ColorTrackView/project.properties",
    "chars": 584,
    "preview": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# T"
  },
  {
    "path": "library_ColorTrackView/res/menu/main.xml",
    "chars": 263,
    "preview": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\r\n\r\n    <item\r\n        android:id=\"@+id/action_setting"
  },
  {
    "path": "library_ColorTrackView/res/values/attr.xml",
    "chars": 809,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <attr name=\"text\" format=\"string\" />\n    <attr name=\"text_size\" "
  },
  {
    "path": "library_ColorTrackView/res/values/dimens.xml",
    "chars": 220,
    "preview": "<resources>\r\n\r\n    <!-- Default screen margins, per the Android Design guidelines. -->\r\n    <dimen name=\"activity_horizo"
  },
  {
    "path": "library_ColorTrackView/res/values/strings.xml",
    "chars": 241,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\r\n\r\n    <string name=\"app_name\">sample_color_change_text</string>\r\n   "
  },
  {
    "path": "library_ColorTrackView/res/values/styles.xml",
    "chars": 697,
    "preview": "<resources>\r\n\r\n    <!--\r\n        Base application theme, dependent on API level. This theme is replaced\n        by AppBa"
  },
  {
    "path": "library_ColorTrackView/res/values-sw600dp/dimens.xml",
    "chars": 203,
    "preview": "<resources>\r\n\r\n    <!--\r\n         Customize dimensions originally defined in res/values/dimens.xml (such as\n         scr"
  },
  {
    "path": "library_ColorTrackView/res/values-sw720dp-land/dimens.xml",
    "chars": 277,
    "preview": "<resources>\r\n\r\n    <!--\r\n         Customize dimensions originally defined in res/values/dimens.xml (such as\n         scr"
  },
  {
    "path": "library_ColorTrackView/res/values-v11/styles.xml",
    "chars": 334,
    "preview": "<resources>\r\n\r\n    <!--\r\n        Base application theme for API 11+. This theme completely replaces\n        AppBaseTheme"
  },
  {
    "path": "library_ColorTrackView/res/values-v14/styles.xml",
    "chars": 391,
    "preview": "<resources>\r\n\r\n    <!--\r\n        Base application theme for API 14+. This theme completely replaces\n        AppBaseTheme"
  },
  {
    "path": "library_ColorTrackView/src/com/zhy/view/ColorTrackView.java",
    "chars": 8983,
    "preview": "package com.zhy.view;\r\n\r\nimport android.content.Context;\r\nimport android.content.res.TypedArray;\r\nimport android.graphic"
  },
  {
    "path": "sample_ColorTrackeView/.classpath",
    "chars": 547,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"src\" "
  },
  {
    "path": "sample_ColorTrackeView/.project",
    "chars": 825,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>sample_ColorTrackeView</name>\n\t<comment></comment>\n\t<"
  },
  {
    "path": "sample_ColorTrackeView/.settings/org.eclipse.jdt.core.prefs",
    "chars": 173,
    "preview": "eclipse.preferences.version=1\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\norg.eclipse.jdt.core.compiler.com"
  },
  {
    "path": "sample_ColorTrackeView/AndroidManifest.xml",
    "chars": 1018,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package="
  },
  {
    "path": "sample_ColorTrackeView/proguard-project.txt",
    "chars": 781,
    "preview": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in t"
  },
  {
    "path": "sample_ColorTrackeView/project.properties",
    "chars": 617,
    "preview": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# T"
  },
  {
    "path": "sample_ColorTrackeView/res/layout/activity_simple_main.xml",
    "chars": 1518,
    "preview": "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n    xmlns:tools=\"http://schemas.android.com/"
  },
  {
    "path": "sample_ColorTrackeView/res/layout/activity_vp_main.xml",
    "chars": 1826,
    "preview": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:zhy=\"http://schemas.android.com/apk/r"
  },
  {
    "path": "sample_ColorTrackeView/res/menu/main.xml",
    "chars": 254,
    "preview": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n\n    <item\n        android:id=\"@+id/action_settings\"\n"
  },
  {
    "path": "sample_ColorTrackeView/res/values/dimens.xml",
    "chars": 213,
    "preview": "<resources>\n\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizonta"
  },
  {
    "path": "sample_ColorTrackeView/res/values/strings.xml",
    "chars": 235,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">sample_viewpagerindicator</string>\n    <"
  },
  {
    "path": "sample_ColorTrackeView/res/values/styles.xml",
    "chars": 680,
    "preview": "<resources>\n\n    <!--\n        Base application theme, dependent on API level. This theme is replaced\n        by AppBaseT"
  },
  {
    "path": "sample_ColorTrackeView/res/values-sw600dp/dimens.xml",
    "chars": 196,
    "preview": "<resources>\n\n    <!--\n         Customize dimensions originally defined in res/values/dimens.xml (such as\n         screen"
  },
  {
    "path": "sample_ColorTrackeView/res/values-sw720dp-land/dimens.xml",
    "chars": 269,
    "preview": "<resources>\n\n    <!--\n         Customize dimensions originally defined in res/values/dimens.xml (such as\n         screen"
  },
  {
    "path": "sample_ColorTrackeView/res/values-v11/styles.xml",
    "chars": 324,
    "preview": "<resources>\n\n    <!--\n        Base application theme for API 11+. This theme completely replaces\n        AppBaseTheme fr"
  },
  {
    "path": "sample_ColorTrackeView/res/values-v14/styles.xml",
    "chars": 381,
    "preview": "<resources>\n\n    <!--\n        Base application theme for API 14+. This theme completely replaces\n        AppBaseTheme fr"
  },
  {
    "path": "sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/HomeActivity.java",
    "chars": 958,
    "preview": "package com.zhy.viewpagerIndicator;\n\nimport android.app.ListActivity;\nimport android.content.Intent;\nimport android.os.B"
  },
  {
    "path": "sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/SimpleUseActivity.java",
    "chars": 946,
    "preview": "package com.zhy.viewpagerIndicator;\r\n\r\nimport android.animation.ObjectAnimator;\r\nimport android.annotation.SuppressLint;"
  },
  {
    "path": "sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/TabFragment.java",
    "chars": 1308,
    "preview": "package com.zhy.viewpagerIndicator;\r\n\r\nimport java.util.Random;\r\n\r\nimport android.graphics.Color;\r\nimport android.os.Bun"
  },
  {
    "path": "sample_ColorTrackeView/src/com/zhy/viewpagerIndicator/ViewPagerUseActivity.java",
    "chars": 2557,
    "preview": "package com.zhy.viewpagerIndicator;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport android.os.Bundle;\r"
  }
]

// ... and 1 more files (download for full content)

About this extraction

This page contains the full source code of the hongyangAndroid/ColorTrackView GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 41 files (43.4 KB), approximately 11.9k tokens, and a symbol index with 50 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!