├── .DS_Store ├── .gitignore ├── .idea ├── checkstyle-idea.xml ├── compiler.xml ├── encodings.xml ├── jarRepositories.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── git-hook.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sign │ │ └── signchart │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── sign │ │ │ └── signchart │ │ │ ├── MainActivity.java │ │ │ └── nestscroll │ │ │ ├── NestScrollActivity.java │ │ │ └── RecyclerFragment.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_nest_scroll.xml │ │ └── fragment_recycler.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.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 │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── sign │ └── signchart │ └── ExampleUnitTest.java ├── build.gradle ├── gif └── example.gif ├── gitHooks └── commit-msg ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── wheelchart ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── sign │ └── wheelchart │ ├── Entry.java │ ├── HorizontalWheelChartView.java │ ├── Utils.java │ └── WheelChartLayout.java └── res └── values ├── attr.xml ├── color.xml └── strings.xml /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongshengdev/WheelChart/0388bd4a43956bb88b8377e170c21df46bce474e/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | -------------------------------------------------------------------------------- /.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WheelChart 2 | **Usage** 3 | 4 | ```implementation 'com.sign.wheelchart:wheelchart:1.1.1'``` 5 | 6 | ``` 7 | 14 | ``` 15 | 16 | **Features** 17 | - 绘制横向图表 18 | - 可拖动并处理惯性滚动事件 19 | - 拖动或惯性滚动结束后,自动选中离中心最近的下标 20 | - 点击图表,根据点击区域选中离点击区域最近的下标 21 | - 处理嵌套滚动 22 | 23 | **blog** 24 | 25 | https://blog.csdn.net/SS_S1gn/article/details/89599605 26 | 27 | **Screens** 28 | 29 | ![](https://github.com/SilenceBurst/WheelChart/blob/master/gif/example.gif) 30 | 31 | **Contributing** 32 | 33 | Yes:) If you found a bug, have an idea how to improve library or have a question, please create new issue or comment existing one. If you would like to contribute code fork the repository and send a pull request. 34 | 35 | **Email** 36 | 37 | yongshengdev@163.com 38 | 39 | **Special Thanks** 40 | 41 | [hencoder](https://hencoder.com/) 42 | https://github.com/totond/BooheeRuler 43 | 44 | **bug fix** 45 | 46 | 1.1.1 第一次打开直接跳转到指定位置; 47 | 将计算最大值、最小值逻辑放在setData中处理 不必特殊计算 48 | y轴单位可修改 49 | 50 | 1.1.0 修复sumsung s6滚动完毕不能回滚到中心区域的bug 51 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply from: 'git-hook.gradle' 3 | 4 | android { 5 | compileSdkVersion 28 6 | defaultConfig { 7 | applicationId "com.sign.signchart" 8 | minSdkVersion 16 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'com.android.support:appcompat-v7:28.0.0' 25 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 26 | testImplementation 'junit:junit:4.12' 27 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 28 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 29 | implementation 'com.android.support:design:28.0.0' 30 | implementation 'com.sign.wheelchart:wheelchart:1.1.1' 31 | } 32 | -------------------------------------------------------------------------------- /app/git-hook.gradle: -------------------------------------------------------------------------------- 1 | /** 2 | * 用法: 3 | * apply from: 'git-hook.gradle' 4 | */ 5 | 6 | /** 7 | * 紧急开关 8 | */ 9 | def forbid = false 10 | 11 | project.afterEvaluate { 12 | if (forbid) { 13 | preBuild.dependsOn 'resetGitHookConfig' 14 | } else { 15 | preBuild.dependsOn 'prepareGitHookConfig' 16 | } 17 | } 18 | 19 | task resetGitHookConfig { 20 | doFirst { 21 | File file = getGitHookFile('commit-msg') 22 | if (file != null) { 23 | file.delete() 24 | } 25 | } 26 | } 27 | 28 | def getGitHookFile(fileName) { 29 | def dirPath = getGitHookDir() 30 | if (dirPath != null && dirPath.length() > 0) { 31 | def file = new File(dirPath, fileName) 32 | if (file.exists()) { 33 | return file 34 | } 35 | } 36 | return null 37 | } 38 | 39 | task prepareGitHookConfig(type: Copy) { 40 | from getConfigFile() 41 | into getGitHookDir() 42 | // 需要添加权限 43 | fileMode 0755 44 | } 45 | 46 | def getConfigFile() { 47 | File configFile = new File(project.rootDir, "gitHooks/commit-msg") 48 | if (configFile.exists()) { 49 | return configFile.absolutePath 50 | } 51 | return null 52 | } 53 | 54 | def getGitHookDir() { 55 | File gitHookDir = new File(project.rootDir, ".git/hooks/") 56 | if (!gitHookDir.exists()) { 57 | println("can't find .git directory in the ${project.rootDir.absolutePath}," + 58 | " please ensure it have been tracked by git!") 59 | return null 60 | } 61 | return gitHookDir.absolutePath 62 | } 63 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sign/signchart/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.sign.signchart; 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 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.sign.signchart", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/sign/signchart/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sign.signchart; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | import android.view.View; 8 | 9 | import com.sign.signchart.nestscroll.NestScrollActivity; 10 | import com.sign.wheelchart.Entry; 11 | import com.sign.wheelchart.HorizontalWheelChartView; 12 | import com.sign.wheelchart.Utils; 13 | import com.sign.wheelchart.WheelChartLayout; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public class MainActivity extends AppCompatActivity { 19 | private static final String TAG = "MainActivity"; 20 | private int mSelectIndex = -1; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_main); 26 | WheelChartLayout wclBillStraight = findViewById(R.id.wcl_bill_straight); 27 | WheelChartLayout wclBillBezier = findViewById(R.id.wcl_bill_bezier); 28 | List list = new ArrayList<>(); 29 | initDemoList(list); 30 | //折线图 31 | float xLabelInterval1 = (Utils.getScreenWidth(this) - Utils.dp2px(this, 40)) / 4f; 32 | wclBillStraight.setXLabelInterval(xLabelInterval1); 33 | wclBillStraight.setInterceptTouchEvent(false); 34 | wclBillStraight.setSelectIndex(0); 35 | wclBillStraight.setData(list); 36 | wclBillStraight.setScrollBackListener(new HorizontalWheelChartView.ScrollBackListener() { 37 | @Override 38 | public void onScrollBack(int selectIndex) { 39 | Log.d(TAG, "onScrollBack selectIndex === " + selectIndex); 40 | if (mSelectIndex != selectIndex) { 41 | mSelectIndex = selectIndex; 42 | Log.d(TAG, "selectIndex has change, can refresh. selectIndex === " + mSelectIndex); 43 | } 44 | } 45 | }); 46 | //贝塞尔连接 47 | float xLabelInterval2 = Utils.getScreenWidth(this) / 4f; 48 | wclBillBezier.setXLabelInterval(xLabelInterval2); 49 | wclBillBezier.setInterceptTouchEvent(false); 50 | wclBillBezier.setSelectIndex(0); 51 | wclBillBezier.setData(list); 52 | } 53 | 54 | public void nestScroll(View view) { 55 | startActivity(new Intent(this, NestScrollActivity.class)); 56 | } 57 | 58 | private void initDemoList(List list) { 59 | list.add(new Entry("Jan", 200)); 60 | list.add(new Entry("Feb", 200)); 61 | list.add(new Entry("Mar", 5000)); 62 | list.add(new Entry("Apr", 5000)); 63 | list.add(new Entry("May", 300)); 64 | list.add(new Entry("Jun", 3000)); 65 | list.add(new Entry("Jul", 5000)); 66 | list.add(new Entry("Aug", 3000)); 67 | list.add(new Entry("Sept", 4500)); 68 | list.add(new Entry("Oct", 2500)); 69 | list.add(new Entry("Nov", 3000)); 70 | list.add(new Entry("Dec", 200)); 71 | list.add(new Entry("Jan", 200)); 72 | list.add(new Entry("Feb", 200)); 73 | list.add(new Entry("Mar", 5000)); 74 | list.add(new Entry("Apr", 5000)); 75 | list.add(new Entry("May", 300)); 76 | list.add(new Entry("Jun", 3000)); 77 | list.add(new Entry("Jul", 5000)); 78 | list.add(new Entry("Aug", 3000)); 79 | list.add(new Entry("Sept", 4500)); 80 | list.add(new Entry("Oct", 2500)); 81 | list.add(new Entry("Nov", 3000)); 82 | list.add(new Entry("Dec", 200)); 83 | list.add(new Entry("Jan", 200)); 84 | list.add(new Entry("Feb", 200)); 85 | list.add(new Entry("Mar", 5000)); 86 | list.add(new Entry("Apr", 5000)); 87 | list.add(new Entry("May", 300)); 88 | list.add(new Entry("Jun", 3000)); 89 | list.add(new Entry("Jul", 5000)); 90 | list.add(new Entry("Aug", 3000)); 91 | list.add(new Entry("Sept", 4500)); 92 | list.add(new Entry("Oct", 2500)); 93 | list.add(new Entry("Nov", 3000)); 94 | list.add(new Entry("Dec", 200)); 95 | list.add(new Entry("Jan", 200)); 96 | list.add(new Entry("Feb", 200)); 97 | list.add(new Entry("Mar", 5000)); 98 | list.add(new Entry("Apr", 5000)); 99 | list.add(new Entry("May", 300)); 100 | list.add(new Entry("Jun", 3000)); 101 | list.add(new Entry("Jul", 5000)); 102 | list.add(new Entry("Aug", 3000)); 103 | list.add(new Entry("Sept", 4500)); 104 | list.add(new Entry("Oct", 2500)); 105 | list.add(new Entry("Nov", 3000)); 106 | list.add(new Entry("Dec", 200)); 107 | list.add(new Entry("Jan", 200)); 108 | list.add(new Entry("Feb", 200)); 109 | list.add(new Entry("Mar", 5000)); 110 | list.add(new Entry("Apr", 5000)); 111 | list.add(new Entry("May", 300)); 112 | list.add(new Entry("Jun", 3000)); 113 | list.add(new Entry("Jul", 5000)); 114 | list.add(new Entry("Aug", 3000)); 115 | list.add(new Entry("Sept", 4500)); 116 | list.add(new Entry("Oct", 2500)); 117 | list.add(new Entry("Nov", 3000)); 118 | list.add(new Entry("Dec", 200)); 119 | list.add(new Entry("Jan", 200)); 120 | list.add(new Entry("Feb", 200)); 121 | list.add(new Entry("Mar", 5000)); 122 | list.add(new Entry("Apr", 5000)); 123 | list.add(new Entry("May", 300)); 124 | list.add(new Entry("Jun", 3000)); 125 | list.add(new Entry("Jul", 5000)); 126 | list.add(new Entry("Aug", 3000)); 127 | list.add(new Entry("Sept", 4500)); 128 | list.add(new Entry("Oct", 2500)); 129 | list.add(new Entry("Nov", 3000)); 130 | list.add(new Entry("Dec", 200)); 131 | list.add(new Entry("Jan", 200)); 132 | list.add(new Entry("Feb", 200)); 133 | list.add(new Entry("Mar", 5000)); 134 | list.add(new Entry("Apr", 5000)); 135 | list.add(new Entry("May", 300)); 136 | list.add(new Entry("Jun", 3000)); 137 | list.add(new Entry("Jul", 5000)); 138 | list.add(new Entry("Aug", 3000)); 139 | list.add(new Entry("Sept", 4500)); 140 | list.add(new Entry("Oct", 2500)); 141 | list.add(new Entry("Nov", 3000)); 142 | list.add(new Entry("Dec", 200)); 143 | list.add(new Entry("Jan", 200)); 144 | list.add(new Entry("Feb", 200)); 145 | list.add(new Entry("Mar", 5000)); 146 | list.add(new Entry("Apr", 5000)); 147 | list.add(new Entry("May", 300)); 148 | list.add(new Entry("Jun", 3000)); 149 | list.add(new Entry("Jul", 5000)); 150 | list.add(new Entry("Aug", 3000)); 151 | list.add(new Entry("Sept", 4500)); 152 | list.add(new Entry("Oct", 2500)); 153 | list.add(new Entry("Nov", 3000)); 154 | list.add(new Entry("Dec", 200)); 155 | list.add(new Entry("Jan", 200)); 156 | list.add(new Entry("Feb", 200)); 157 | list.add(new Entry("Mar", 5000)); 158 | list.add(new Entry("Apr", 5000)); 159 | list.add(new Entry("May", 300)); 160 | list.add(new Entry("Jun", 3000)); 161 | list.add(new Entry("Jul", 5000)); 162 | list.add(new Entry("Aug", 3000)); 163 | list.add(new Entry("Sept", 4500)); 164 | list.add(new Entry("Oct", 2500)); 165 | list.add(new Entry("Nov", 3000)); 166 | list.add(new Entry("Dec", 200)); 167 | list.add(new Entry("Jan", 200)); 168 | list.add(new Entry("Feb", 200)); 169 | list.add(new Entry("Mar", 5000)); 170 | list.add(new Entry("Apr", 5000)); 171 | list.add(new Entry("May", 300)); 172 | list.add(new Entry("Jun", 3000)); 173 | list.add(new Entry("Jul", 5000)); 174 | list.add(new Entry("Aug", 3000)); 175 | list.add(new Entry("Sept", 4500)); 176 | list.add(new Entry("Oct", 2500)); 177 | list.add(new Entry("Nov", 3000)); 178 | list.add(new Entry("Dec", 200)); 179 | list.add(new Entry("Jan", 200)); 180 | list.add(new Entry("Feb", 200)); 181 | list.add(new Entry("Mar", 5000)); 182 | list.add(new Entry("Apr", 5000)); 183 | list.add(new Entry("May", 300)); 184 | list.add(new Entry("Jun", 3000)); 185 | list.add(new Entry("Jul", 5000)); 186 | list.add(new Entry("Aug", 3000)); 187 | list.add(new Entry("Sept", 4500)); 188 | list.add(new Entry("Oct", 2500)); 189 | list.add(new Entry("Nov", 3000)); 190 | list.add(new Entry("Dec", 200)); 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /app/src/main/java/com/sign/signchart/nestscroll/NestScrollActivity.java: -------------------------------------------------------------------------------- 1 | package com.sign.signchart.nestscroll; 2 | 3 | import android.support.annotation.Nullable; 4 | import android.support.design.widget.TabLayout; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentPagerAdapter; 7 | import android.support.v4.view.ViewPager; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | 11 | import com.sign.signchart.R; 12 | import com.sign.wheelchart.Entry; 13 | import com.sign.wheelchart.Utils; 14 | import com.sign.wheelchart.WheelChartLayout; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class NestScrollActivity extends AppCompatActivity { 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_nest_scroll); 25 | 26 | WheelChartLayout chartBillLayout = findViewById(R.id.cbl_bill); 27 | List list = new ArrayList<>(); 28 | list.add(new Entry("Jan", 200)); 29 | list.add(new Entry("Feb", 200)); 30 | list.add(new Entry("Mar", 5000)); 31 | list.add(new Entry("Apr", 5000)); 32 | list.add(new Entry("May", 300)); 33 | list.add(new Entry("Jun", 3000)); 34 | list.add(new Entry("Jul", 5000)); 35 | list.add(new Entry("Aug", 3000)); 36 | list.add(new Entry("Sept", 4500)); 37 | list.add(new Entry("Oct", 2500)); 38 | list.add(new Entry("Nov", 3000)); 39 | list.add(new Entry("Dec", 200)); 40 | float xLabelInterval = Utils.getScreenWidth(this) / 4f; 41 | chartBillLayout.setXLabelInterval(xLabelInterval); 42 | chartBillLayout.setInterceptTouchEvent(false); 43 | chartBillLayout.setSelectIndex(0); 44 | chartBillLayout.setData(list); 45 | ViewPager viewPager = findViewById(R.id.view_pager); 46 | viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) { 47 | @Override 48 | public Fragment getItem(int position) { 49 | return new RecyclerFragment(); 50 | } 51 | 52 | @Override 53 | public int getCount() { 54 | return 6; 55 | } 56 | 57 | @Nullable 58 | @Override 59 | public CharSequence getPageTitle(int position) { 60 | return "分类" + position; 61 | } 62 | }); 63 | TabLayout tabLayout = findViewById(R.id.tab_layout); 64 | tabLayout.setupWithViewPager(viewPager); 65 | tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/sign/signchart/nestscroll/RecyclerFragment.java: -------------------------------------------------------------------------------- 1 | package com.sign.signchart.nestscroll; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.NonNull; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.support.v7.widget.LinearLayoutManager; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.Gravity; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.TextView; 14 | import com.sign.signchart.R; 15 | 16 | /** 17 | * Created by cys on 2018/8/17 0017. 18 | */ 19 | public class RecyclerFragment extends Fragment { 20 | @Nullable 21 | @Override 22 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 23 | return inflater.inflate(R.layout.fragment_recycler, container, false); 24 | } 25 | 26 | @Override 27 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { 28 | super.onViewCreated(view, savedInstanceState); 29 | RecyclerView recyclerView = view.findViewById(R.id.recycler_view); 30 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); 31 | recyclerView.setAdapter(new RecyclerView.Adapter() { 32 | @NonNull 33 | @Override 34 | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 35 | TextView textView = new TextView(getActivity()); 36 | textView.setText("条目 in RecyclerView"); 37 | textView.setHeight(100); 38 | textView.setGravity(Gravity.CENTER); 39 | 40 | return new RecyclerView.ViewHolder(textView) { 41 | }; 42 | } 43 | 44 | @Override 45 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { 46 | 47 | } 48 | 49 | @Override 50 | public int getItemCount() { 51 | return 30; 52 | } 53 | }); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | 28 | 29 | 35 | 36 | 43 | 44 |