├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── kotlinc.xml ├── misc.xml ├── modules.xml ├── qaplug_profiles.xml └── runConfigurations.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── center │ │ └── testviewpager │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── center │ │ │ └── testviewpager │ │ │ ├── MainActivity.java │ │ │ └── MyApplication.java │ └── res │ │ ├── drawable │ │ ├── splash_iv_first.png │ │ ├── splash_iv_forth.png │ │ ├── splash_iv_second.png │ │ └── splash_iv_third.png │ │ ├── layout │ │ ├── activity_main.xml │ │ └── layout_app_intro.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── arrays.xml │ │ ├── colors-material.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── center │ └── testviewpager │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | 44 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 1.8 79 | 80 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/qaplug_profiles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 919 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TestViewpager- 2 | Android引导页根据滑动渐变背景色 3 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.center.testviewpager" 8 | minSdkVersion 14 9 | targetSdkVersion 25 10 | versionCode 2 11 | versionName "1.1" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | multiDexEnabled true 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 26 | exclude group: 'com.android.support', module: 'support-annotations' 27 | }) 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.android.support:support-v4:25.1.0' 30 | //沉浸式状态栏 31 | compile 'com.jaeger.statusbaruitl:library:1.3.6' 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/center/testviewpager/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.center.testviewpager; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest 19 | { 20 | @Test 21 | public void useAppContext() throws Exception 22 | { 23 | // Context of the app under test. 24 | Context appContext = InstrumentationRegistry.getTargetContext(); 25 | 26 | assertEquals("com.center.testviewpager", appContext.getPackageName()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/center/testviewpager/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.center.testviewpager; 2 | 3 | import android.animation.ArgbEvaluator; 4 | import android.app.Activity; 5 | import android.content.res.TypedArray; 6 | import android.os.Build; 7 | import android.os.Bundle; 8 | import android.support.v4.content.ContextCompat; 9 | import android.support.v4.view.PagerAdapter; 10 | import android.support.v4.view.ViewPager; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.view.WindowManager; 14 | import android.widget.Button; 15 | import android.widget.ImageView; 16 | import android.widget.RelativeLayout; 17 | import android.widget.TextView; 18 | 19 | import com.jaeger.library.StatusBarUtil; 20 | 21 | public class MainActivity extends Activity 22 | { 23 | 24 | private RelativeLayout mRootLayout; 25 | 26 | private ViewPager mViewPager; 27 | 28 | private int colorBg[]; 29 | 30 | private ArgbEvaluator mArgbEvaluator; 31 | 32 | private int barAlpha = 0; 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) 36 | { 37 | super.onCreate(savedInstanceState); 38 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) 39 | { 40 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 41 | } 42 | setContentView(R.layout.activity_main); 43 | mRootLayout = (RelativeLayout)findViewById(R.id.rl_root); 44 | mViewPager = (ViewPager)findViewById(R.id.viewpager); 45 | StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.light_green_500), barAlpha); 46 | mArgbEvaluator = new ArgbEvaluator(); 47 | colorBg = getResources().getIntArray(R.array.splash_bg); 48 | final IntroPager introPager = new IntroPager(R.array.splash_icon, R.array.splash_desc); 49 | mViewPager.setAdapter(introPager); 50 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() 51 | { 52 | @Override 53 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) 54 | { 55 | int color = (int)mArgbEvaluator.evaluate(positionOffset, colorBg[position % colorBg.length], 56 | colorBg[(position + 1) % colorBg.length]); 57 | StatusBarUtil.setColor(MainActivity.this, color, barAlpha); 58 | mRootLayout.setBackgroundColor(color); 59 | } 60 | 61 | @Override 62 | public void onPageSelected(int position) 63 | { 64 | 65 | } 66 | 67 | @Override 68 | public void onPageScrollStateChanged(int state) 69 | { 70 | 71 | } 72 | 73 | }); 74 | 75 | } 76 | 77 | private class IntroPager extends PagerAdapter 78 | { 79 | 80 | private String[] mDescs; 81 | 82 | private TypedArray mIcons; 83 | 84 | public IntroPager(int icoImage, int des) 85 | { 86 | mDescs = getResources().getStringArray(des); 87 | mIcons = getResources().obtainTypedArray(icoImage); 88 | } 89 | 90 | @Override 91 | public int getCount() 92 | { 93 | return mIcons.length(); 94 | } 95 | 96 | @Override 97 | public boolean isViewFromObject(View view, Object object) 98 | { 99 | return view == object; 100 | } 101 | 102 | @Override 103 | public Object instantiateItem(ViewGroup container, int position) 104 | { 105 | View itemLayout = getLayoutInflater().inflate(R.layout.layout_app_intro, container, false); 106 | ImageView mImage = (ImageView)itemLayout.findViewById(R.id.iv_img); 107 | TextView mTextView = (TextView)itemLayout.findViewById(R.id.tv_desc); 108 | Button mButton = (Button)itemLayout.findViewById(R.id.btn_launch); 109 | mImage.setImageResource(mIcons.getResourceId(position, 0)); 110 | mTextView.setText(mDescs[position]); 111 | if (position == getCount() - 1) 112 | { 113 | mButton.setVisibility(View.VISIBLE); 114 | } 115 | else 116 | { 117 | mButton.setVisibility(View.GONE); 118 | } 119 | container.addView(itemLayout); 120 | return itemLayout; 121 | } 122 | 123 | @Override 124 | public void destroyItem(ViewGroup container, int position, Object object) 125 | { 126 | container.removeView((View)object); 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /app/src/main/java/com/center/testviewpager/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.center.testviewpager; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * Created by Android-center on 2017/3/23. 7 | */ 8 | 9 | public class MyApplication extends Application 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/splash_iv_first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centerzx/TestViewpager-/89fd84ac5dddfb44f942b294fbac30320cf18779/app/src/main/res/drawable/splash_iv_first.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/splash_iv_forth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centerzx/TestViewpager-/89fd84ac5dddfb44f942b294fbac30320cf18779/app/src/main/res/drawable/splash_iv_forth.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/splash_iv_second.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centerzx/TestViewpager-/89fd84ac5dddfb44f942b294fbac30320cf18779/app/src/main/res/drawable/splash_iv_second.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/splash_iv_third.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centerzx/TestViewpager-/89fd84ac5dddfb44f942b294fbac30320cf18779/app/src/main/res/drawable/splash_iv_third.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_app_intro.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 17 | 18 | 19 | 23 | 24 | 33 | 34 |