Initial commit

This commit is contained in:
Little Mango
2018-07-03 16:04:08 +08:00
commit c6eda5705d
72 changed files with 2053 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

55
.gitignore vendored Normal file
View File

@ -0,0 +1,55 @@
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries
# Keystore files
*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json

47
.idea/assetWizardSettings.xml generated Normal file
View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="vectorWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="vectorAssetStep">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipartAsset">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="url" value="jar:file:/Applications/Android%20Studio.app/Contents/plugins/android/lib/android.jar!/images/material_design_icons/toggle/ic_star_black_24dp.xml" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="color" value="ffffff" />
<entry key="outputName" value="ic_star_black_24dp" />
<entry key="sourceFile" value="$USER_HOME$" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>

BIN
.idea/caches/build_file_checksums.ser generated Normal file

Binary file not shown.

17
.idea/checkstyle-idea.xml generated Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CheckStyle-IDEA">
<option name="configuration">
<map>
<entry key="active-configuration" value="BUNDLED:(bundled):Google Checks" />
<entry key="checkstyle-version" value="8.7" />
<entry key="copy-libs" value="false" />
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
<entry key="scan-before-checkin" value="false" />
<entry key="scanscope" value="JavaOnly" />
<entry key="suppress-errors" value="false" />
</map>
</option>
</component>
</project>

29
.idea/codeStyles/Project.xml generated Normal file
View File

@ -0,0 +1,29 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

34
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

10
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/StackLayoutManager/StackLayoutManager.iml" filepath="$PROJECT_DIR$/StackLayoutManager/StackLayoutManager.iml" />
<module fileurl="file://$PROJECT_DIR$/StackLayoutManagerMaster.iml" filepath="$PROJECT_DIR$/StackLayoutManagerMaster.iml" />
<module fileurl="file://$PROJECT_DIR$/sample/sample.iml" filepath="$PROJECT_DIR$/sample/sample.iml" />
</modules>
</component>
</project>

12
.idea/runConfigurations.xml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Little Mango
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1
README.md Normal file
View File

@ -0,0 +1 @@
# StackLayoutManager

1
StackLayoutManager/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -0,0 +1,37 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:recyclerview-v7:27.1.1'
}
repositories {
mavenCentral()
}

21
StackLayoutManager/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# 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 *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -0,0 +1,26 @@
package com.littlemango.stacklayoutmanager;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.littlemango.stacklayoutmanager.test", appContext.getPackageName());
}
}

View File

@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.littlemango.stacklayoutmanager" />

View File

@ -0,0 +1,121 @@
package com.littlemango.stacklayoutmanager
import android.view.View
import com.littlemango.stacklayoutmanager.StackLayoutManager.ScrollOrientation
class DefaultAnimation(scrollOrientation: ScrollOrientation, visibleCount: Int) : StackAnimation(scrollOrientation, visibleCount) {
private var mScale = 0.95f
private var mOutScale = 0.8f
private var mOutRotation: Int
init {
mOutRotation = when(scrollOrientation) {
ScrollOrientation.LEFT_TO_RIGHT, ScrollOrientation.RIGHT_TO_LEFT -> 10
else -> 0
}
}
/**
* 设置 item 缩放比例.
* @param scale 缩放比例默认是0.95f.
*/
fun setItemScaleRate(scale: Float) {
mScale = scale
}
/**
* 获取item缩放比例.
* @return item缩放比例默认是0.95f.
*/
fun getItemScaleRate(): Float {
return mScale
}
/**
* 设置 itemView 离开屏幕时候的缩放比例.
* @param scale 缩放比例默认是0.8f.
*/
fun setOutScale(scale: Float) {
mOutScale = scale
}
/**
* 获取 itemView 离开屏幕时候的缩放比例.
* @return 缩放比例默认是0.8f.
*/
fun getOutScale(): Float {
return mOutScale
}
/**
* 设置 itemView 离开屏幕时候的旋转角度.
* @param rotation 旋转角度默认是30.
*/
fun setOutRotation(rotation: Int) {
mOutRotation = rotation
}
/**
* 获取 itemView 离开屏幕时候的旋转角度
* @return 旋转角度默认是30
*/
fun getOutRotation(): Int {
return mOutRotation
}
override fun doAnimation(movePercent: Float, itemView: View, position: Int) {
val scale: Float
var alpha = 1.0f
val rotation: Float
if (position == 0) {
scale = 1 - ((1 - mOutScale) * movePercent)
rotation = mOutRotation * movePercent
} else {
val minScale = (Math.pow(mScale.toDouble(), position.toDouble())).toFloat()
val maxScale = (Math.pow(mScale.toDouble(), (position - 1).toDouble())).toFloat()
scale = minScale + (maxScale - minScale) * movePercent
//只对最后一个 item 做透明度变化
if (position == mVisibleCount) {
alpha = movePercent
}
rotation = 0f
}
setItemPivotXY(mScrollOrientation, itemView)
rotationFirstVisibleItem(mScrollOrientation, itemView, rotation)
itemView.scaleX = scale
itemView.scaleY = scale
itemView.alpha = alpha
}
private fun setItemPivotXY(scrollOrientation: ScrollOrientation, view: View) {
when(scrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT -> {
view.pivotX = view.measuredWidth.toFloat()
view.pivotY = view.measuredHeight.toFloat() / 2
}
ScrollOrientation.LEFT_TO_RIGHT -> {
view.pivotX = 0f
view.pivotY = view.measuredHeight.toFloat() / 2
}
ScrollOrientation.BOTTOM_TO_TOP -> {
view.pivotX = view.measuredWidth.toFloat() /2
view.pivotY = view.measuredHeight.toFloat()
}
ScrollOrientation.TOP_TO_BOTTOM -> {
view.pivotX = view.measuredWidth.toFloat() / 2
view.pivotY = 0f
}
}
}
private fun rotationFirstVisibleItem(scrollOrientation: ScrollOrientation, view: View, rotation: Float) {
when(scrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT -> view.rotationY = rotation
ScrollOrientation.LEFT_TO_RIGHT -> view.rotationY = -rotation
ScrollOrientation.BOTTOM_TO_TOP -> view.rotationX = -rotation
ScrollOrientation.TOP_TO_BOTTOM -> view.rotationX = rotation
}
}
}

View File

@ -0,0 +1,100 @@
package com.littlemango.stacklayoutmanager
import android.view.View
class DefaultLayout(scrollOrientation: StackLayoutManager.ScrollOrientation,
visibleCount: Int,
perItemOffset: Int) : StackLayout(scrollOrientation, visibleCount, perItemOffset) {
private var mHasMeasureItemSize = false
private var mWidthSpace = 0
private var mHeightSpace = 0
private var mStartMargin = 0
private var mWidth = 0
private var mHeight = 0
private var mScrollOffset = 0
override fun doLayout(stackLayoutManager: StackLayoutManager, scrollOffset: Int, firstMovePercent: Float, itemView: View, position: Int) {
mWidth = stackLayoutManager.width
mHeight = stackLayoutManager.height
mScrollOffset = scrollOffset
if (!mHasMeasureItemSize) {
mWidthSpace = mWidth - stackLayoutManager.getDecoratedMeasuredWidth(itemView)
mHeightSpace = mHeight - stackLayoutManager.getDecoratedMeasuredHeight(itemView)
mStartMargin = getStartMargin()
mHasMeasureItemSize = true
}
val left: Int
val top: Int
if (position == 0) {
left = getFirstVisibleItemLeft()
top = getFirstVisibleItemTop()
} else {
left = getAfterFirstVisibleItemLeft(position, firstMovePercent)
top = getAfterFirstVisibleItemTop(position, firstMovePercent)
}
val right = left + stackLayoutManager.getDecoratedMeasuredWidth(itemView)
val bottom = top + stackLayoutManager.getDecoratedMeasuredHeight(itemView)
stackLayoutManager.layoutDecorated(itemView, left, top, right, bottom)
}
override fun requestLayout() {
mHasMeasureItemSize = false //表示尺寸可能发生了改变
}
private fun getFirstVisibleItemLeft(): Int {
return when(mScrollOrientation) {
StackLayoutManager.ScrollOrientation.RIGHT_TO_LEFT -> mStartMargin - mScrollOffset % mWidth
StackLayoutManager.ScrollOrientation.LEFT_TO_RIGHT -> {
return if (mScrollOffset % mWidth == 0) {
mStartMargin
} else {
mStartMargin + (mWidth - mScrollOffset % mWidth)
}
}
else -> mWidthSpace / 2
}
}
private fun getFirstVisibleItemTop(): Int {
return when(mScrollOrientation) {
StackLayoutManager.ScrollOrientation.BOTTOM_TO_TOP -> mStartMargin - mScrollOffset % mHeight
StackLayoutManager.ScrollOrientation.TOP_TO_BOTTOM -> {
return if (mScrollOffset % mHeight == 0) {
mStartMargin
} else {
mStartMargin + (mHeight - mScrollOffset % mHeight)
}
}
else -> mHeightSpace / 2
}
}
private fun getAfterFirstVisibleItemLeft(visiblePosition: Int, movePercent: Float): Int {
return when(mScrollOrientation) {
StackLayoutManager.ScrollOrientation.RIGHT_TO_LEFT -> (mStartMargin + mPerItemOffset * (visiblePosition - movePercent)).toInt()
StackLayoutManager.ScrollOrientation.LEFT_TO_RIGHT -> (mStartMargin - mPerItemOffset * (visiblePosition - movePercent)).toInt()
else -> mWidthSpace / 2
}
}
private fun getAfterFirstVisibleItemTop(visiblePosition: Int, movePercent: Float): Int {
return when(mScrollOrientation) {
StackLayoutManager.ScrollOrientation.BOTTOM_TO_TOP -> (mStartMargin + mPerItemOffset * (visiblePosition - movePercent)).toInt()
StackLayoutManager.ScrollOrientation.TOP_TO_BOTTOM -> (mStartMargin - mPerItemOffset * (visiblePosition - movePercent)).toInt()
else -> mHeightSpace / 2
}
}
private fun getStartMargin(): Int {
return when(mScrollOrientation) {
StackLayoutManager.ScrollOrientation.RIGHT_TO_LEFT, StackLayoutManager.ScrollOrientation.LEFT_TO_RIGHT -> mWidthSpace / 2
else -> mHeightSpace / 2
}
}
}

View File

@ -0,0 +1,22 @@
package com.littlemango.stacklayoutmanager
import android.view.View
import com.littlemango.stacklayoutmanager.StackLayoutManager.ScrollOrientation
abstract class StackAnimation(scrollOrientation: ScrollOrientation, visibleCount: Int) {
protected val mScrollOrientation = scrollOrientation
protected var mVisibleCount = visibleCount
internal fun setVisibleCount(visibleCount: Int) {
mVisibleCount = visibleCount
}
/**
* 外部回调,用来做动画.
* @param firstMovePercent 第一个可视 item 移动的百分比,当即将完全移出屏幕的时候 firstMovePercent无限接近1.
* @param itemView 当前的 itemView.
* @param position 当前 itemView 对应的位置position = 0 until visibleCount.
*/
abstract fun doAnimation(firstMovePercent: Float, itemView: View, position: Int)
}

View File

@ -0,0 +1,34 @@
package com.littlemango.stacklayoutmanager
import android.view.View
abstract class StackLayout(scrollOrientation: StackLayoutManager.ScrollOrientation,
visibleCount: Int,
perItemOffset: Int) {
protected val mScrollOrientation = scrollOrientation
protected var mVisibleCount = visibleCount
protected var mPerItemOffset = perItemOffset
internal fun setItemOffset(offset: Int) {
mPerItemOffset = offset
}
internal fun getItemOffset(): Int {
return mPerItemOffset
}
/**
* 外部回调,用来做布局.
* @param firstMovePercent 第一个可视 item 移动的百分比,当即将完全移出屏幕的时候 firstMovePercent无限接近1.
* @param itemView 当前的 itemView.
* @param position 当前 itemView 对应的位置position = 0 until visibleCount.
*/
abstract fun doLayout(stackLayoutManager: StackLayoutManager,
scrollOffset: Int,
firstMovePercent: Float,
itemView: View,
position: Int)
abstract fun requestLayout()
}

View File

@ -0,0 +1,481 @@
package com.littlemango.stacklayoutmanager
import android.support.annotation.IntRange
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.RecyclerView.SCROLL_STATE_DRAGGING
import android.support.v7.widget.RecyclerView.SCROLL_STATE_IDLE
import android.view.View
import android.view.ViewGroup
class StackLayoutManager(scrollOrientation: ScrollOrientation,
visibleCount: Int,
animation: Class<out StackAnimation>,
layout: Class<out StackLayout>) : RecyclerView.LayoutManager() {
private enum class FlingOrientation{NONE, LEFT_TO_RIGHT, RIGHT_TO_LEFT, TOP_TO_BOTTOM, BOTTOM_TO_TOP}
enum class ScrollOrientation{LEFT_TO_RIGHT, RIGHT_TO_LEFT, TOP_TO_BOTTOM, BOTTOM_TO_TOP}
private var mVisibleItemCount = visibleCount
private var mScrollOrientation = scrollOrientation
private var mScrollOffset: Int
private lateinit var mOnScrollListener: RecyclerView.OnScrollListener
private lateinit var mOnFlingListener: RecyclerView.OnFlingListener
//做动画的组件,支持自定义
private var mAnimation: StackAnimation? = null
//做布局的组件,支持自定义
private var mLayout: StackLayout? = null
//是否是翻页效果
private var mPagerMode = true
//触发翻页效果的最低 Fling速度
private var mPagerFlingVelocity = 0
//标志当前滚动是否是调用{@link #scrollToCenter(Int, RecyclerView, Boolean)}之后触发的滚动
private var mFixScrolling = false
//fling的方向用来判断是前翻还是后翻
private var mFlingOrientation = FlingOrientation.NONE
init {
mScrollOffset = when(mScrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT, ScrollOrientation.BOTTOM_TO_TOP -> 0
else -> Int.MAX_VALUE
}
if (StackAnimation::class.java.isAssignableFrom(animation)) {
try {
val cla = animation.getDeclaredConstructor(ScrollOrientation::class.java, Int::class.javaPrimitiveType)
mAnimation = cla.newInstance(scrollOrientation, visibleCount) as StackAnimation
} catch (e: Exception) {
e.printStackTrace()
}
}
if (StackLayout::class.java.isAssignableFrom(layout)) {
try {
val cla = layout.getDeclaredConstructor(ScrollOrientation::class.java, Int::class.javaPrimitiveType, Int::class.javaPrimitiveType)
mLayout = cla.newInstance(scrollOrientation, visibleCount, 30) as StackLayout
} catch (e: Exception) {
e.printStackTrace()
}
}
}
/**
* 设置是否为ViewPager 式翻页模式.
* <p>
* 当设置为 true 的时候,可以配合{@link #setPagerFlingVelocity(Int)} 设置触发翻页的最小速度.
* @param isPagerMode 这个值默认是 false当设置为 true 的时候,会有 viewPager 翻页效果.
*/
fun setPagerMode(isPagerMode: Boolean) {
mPagerMode = isPagerMode
}
/**
* @return 当前是否为ViewPager翻页模式.
*/
fun getPagerMode(): Boolean {
return mPagerMode
}
/**
* 设置触发ViewPager翻页效果的最小速度.
* <p>
* 该值仅在 {@link #getPagerMode() == true}的时候有效.
* @param velocity 默认值是2000.
*/
fun setPagerFlingVelocity(@IntRange(from = 0, to = Int.MAX_VALUE.toLong()) velocity: Int) {
mPagerFlingVelocity = Math.min(Int.MAX_VALUE, Math.max(0, velocity))
}
/**
* @return 当前触发翻页的最小 fling 速度.
*/
fun getPagerFlingVelocity(): Int {
return mPagerFlingVelocity
}
/**
* 设置recyclerView 静止时候可见的itemView 个数.
* @param count 可见 itemView默认为3
*/
fun setVisibleItemCount(@IntRange(from = 1, to = Long.MAX_VALUE)count: Int) {
mVisibleItemCount = Math.min(itemCount - 1, Math.max(1, count))
mAnimation?.setVisibleCount(mVisibleItemCount)
}
/**
* 获取recyclerView 静止时候可见的itemView 个数.
* @return 静止时候可见的itemView 个数默认为3.
*/
fun getVisibleItemCount(): Int {
return mVisibleItemCount
}
/**
* 设置 item 偏移值,即第 i 个 item 相对于 第 i-1个 item 在水平方向的偏移值默认是40px.
* @param offset 每个 item 相对于前一个的偏移值.
*/
fun setItemOffset(offset: Int) {
mLayout?.setItemOffset(offset)
}
/**
* 获取每个 item 相对于前一个的水平偏移值.
* @return 每个 item 相对于前一个的水平偏移值.
*/
fun getItemOffset(): Int {
return if (mLayout == null) {
0
} else {
mLayout!!.getItemOffset()
}
}
/**
* 设置item 移动动画.
* @param animation item 移动动画.
*/
fun setAnimation(animation: StackAnimation) {
mAnimation = animation
}
/**
* 获取 item 移动动画.
* @return item 移动动画.
*/
fun getAnimation(): StackAnimation? {
return mAnimation
}
/**
* 获取StackLayoutManager 的滚动方向.
* @return StackLayoutManager 的滚动方向.
*/
fun getScrollOrientation(): ScrollOrientation {
return mScrollOrientation
}
constructor(scrollOrientation: ScrollOrientation) : this(scrollOrientation, 3, DefaultAnimation::class.java, DefaultLayout::class.java)
constructor(scrollOrientation: ScrollOrientation, visibleCount: Int) : this(scrollOrientation, visibleCount, DefaultAnimation::class.java, DefaultLayout::class.java)
constructor() : this(ScrollOrientation.RIGHT_TO_LEFT)
override fun generateDefaultLayoutParams(): RecyclerView.LayoutParams {
return RecyclerView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
}
override fun onAttachedToWindow(view: RecyclerView) {
super.onAttachedToWindow(view)
mOnFlingListener = object : RecyclerView.OnFlingListener() {
override fun onFling(velocityX: Int, velocityY: Int): Boolean {
if (mPagerMode) {
when(mScrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT, ScrollOrientation.LEFT_TO_RIGHT -> {
mFlingOrientation = when {
velocityX > mPagerFlingVelocity -> FlingOrientation.RIGHT_TO_LEFT
velocityX < -mPagerFlingVelocity -> FlingOrientation.LEFT_TO_RIGHT
else -> FlingOrientation.NONE
}
if (mScrollOffset in 1 until width * (itemCount - 1)) { //边界不需要滚动
mFixScrolling = true
}
}
else -> {
mFlingOrientation = when {
velocityY > mPagerFlingVelocity -> FlingOrientation.BOTTOM_TO_TOP
velocityY < -mPagerFlingVelocity -> FlingOrientation.TOP_TO_BOTTOM
else -> FlingOrientation.NONE
}
if (mScrollOffset in 1 until width * (itemCount - 1)) { //边界不需要滚动
mFixScrolling = true
}
}
}
calculateAndScrollToTarget(view)
}
return mPagerMode
}
}
view.onFlingListener = mOnFlingListener
mOnScrollListener = object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
if (newState == SCROLL_STATE_IDLE) {
if (!mFixScrolling) {
mFixScrolling = true
calculateAndScrollToTarget(view)
} else {
//表示此次 IDLE 是由修正位置结束触发的
mFixScrolling = false
}
} else if (newState == SCROLL_STATE_DRAGGING) {
mFixScrolling = false
}
}
}
view.addOnScrollListener(mOnScrollListener)
}
override fun onDetachedFromWindow(view: RecyclerView?, recycler: RecyclerView.Recycler?) {
super.onDetachedFromWindow(view, recycler)
if (view?.onFlingListener == mOnFlingListener) {
view.onFlingListener = null
}
view?.removeOnScrollListener(mOnScrollListener)
}
override fun canScrollHorizontally(): Boolean {
return when(mScrollOrientation) {
ScrollOrientation.LEFT_TO_RIGHT, ScrollOrientation.RIGHT_TO_LEFT -> true
else -> false
}
}
override fun canScrollVertically(): Boolean {
return when(mScrollOrientation) {
ScrollOrientation.TOP_TO_BOTTOM, ScrollOrientation.BOTTOM_TO_TOP -> true
else -> false
}
}
override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State) {
mLayout?.requestLayout()
removeAndRecycleAllViews(recycler)
mScrollOffset = getValidOffset(mScrollOffset)
loadItemView(recycler)
}
override fun scrollHorizontallyBy(dx: Int, recycler: RecyclerView.Recycler, state: RecyclerView.State): Int {
return handleScrollBy(dx, recycler)
}
override fun scrollVerticallyBy(dy: Int, recycler: RecyclerView.Recycler, state: RecyclerView.State?): Int {
return handleScrollBy(dy, recycler)
}
override fun scrollToPosition(position: Int) {
if (position < 0 || position >= itemCount) {
throw ArrayIndexOutOfBoundsException("$position is out of bound [0..$itemCount-1]")
}
mScrollOffset = getPositionOffset(position)
requestLayout()
}
override fun smoothScrollToPosition(recyclerView: RecyclerView, state: RecyclerView.State?, position: Int) {
if (position < 0 || position >= itemCount) {
throw ArrayIndexOutOfBoundsException("$position is out of bound [0..$itemCount-1]")
}
mFixScrolling = true
scrollToCenter(position, recyclerView, true)
}
private fun handleScrollBy(offset: Int, recycler: RecyclerView.Recycler): Int {
//期望值,不得超过最大最小值,所以期望值不一定等于实际值
val expectOffset = mScrollOffset + offset
//实际值
mScrollOffset = getValidOffset(expectOffset)
//实际偏移超过最大最小值之后的偏移都应该是0该值作为返回值否则在极限位置进行滚动的时候不会出现弹性阴影
val exactMove = mScrollOffset - expectOffset + offset
if (exactMove == 0) {
//itemViews 位置都不会改变,直接 return
return 0
}
detachAndScrapAttachedViews(recycler)
loadItemView(recycler)
return exactMove
}
private fun loadItemView(recycler: RecyclerView.Recycler) {
val firstVisiblePosition = getFirstVisibleItemPosition()
val lastVisiblePosition = getLastVisibleItemPosition()
//位移百分比
val movePercent = getFirstVisibleItemMovePercent()
for (i in lastVisiblePosition downTo firstVisiblePosition) {
val view = recycler.getViewForPosition(i)
//添加到recycleView 中
addView(view)
//测量
measureChild(view, 0, 0)
//布局
mLayout?.doLayout(this, mScrollOffset, movePercent, view, i - firstVisiblePosition)
//做动画
mAnimation?.doAnimation(movePercent, view, i - firstVisiblePosition)
}
//重用
if (firstVisiblePosition - 1 >= 0) {
val view = recycler.getViewForPosition(firstVisiblePosition - 1)
resetViewAnimateProperty(view)
removeAndRecycleView(view, recycler)
}
if (lastVisiblePosition + 1 < itemCount) {
val view = recycler.getViewForPosition(lastVisiblePosition + 1)
resetViewAnimateProperty(view)
removeAndRecycleView(view, recycler)
}
}
private fun resetViewAnimateProperty(view: View) {
view.rotationY = 0f
view.rotationX = 0f
view.scaleX = 1f
view.scaleY = 1f
view.alpha = 1f
}
private fun calculateAndScrollToTarget(view: RecyclerView) {
val targetPosition = calculateCenterPosition(getFirstVisibleItemPosition())
scrollToCenter(targetPosition, view, true)
}
private fun scrollToCenter(targetPosition: Int, recyclerView: RecyclerView, animation: Boolean) {
val targetOffset = getPositionOffset(targetPosition)
when(mScrollOrientation) {
ScrollOrientation.LEFT_TO_RIGHT, ScrollOrientation.RIGHT_TO_LEFT -> {
if (animation) {
recyclerView.smoothScrollBy(targetOffset - mScrollOffset, 0)
} else {
recyclerView.scrollBy(targetOffset - mScrollOffset, 0)
}
}
else -> {
if (animation) {
recyclerView.smoothScrollBy(0, targetOffset - mScrollOffset)
} else {
recyclerView.scrollBy(0, targetOffset - mScrollOffset)
}
}
}
}
private fun getValidOffset(expectOffset: Int): Int {
return when(mScrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT, ScrollOrientation.LEFT_TO_RIGHT -> Math.max(Math.min(width * (itemCount - 1), expectOffset), 0)
else -> Math.max(Math.min(height * (itemCount - 1), expectOffset), 0)
}
}
private fun getPositionOffset(position: Int): Int {
return when(mScrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT -> position * width
ScrollOrientation.LEFT_TO_RIGHT -> (itemCount - 1 - position) * width
ScrollOrientation.BOTTOM_TO_TOP -> position * height
ScrollOrientation.TOP_TO_BOTTOM -> (itemCount - 1 - position) * height
}
}
private fun getFirstVisibleItemPosition(): Int {
return when(mScrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT -> Math.floor((mScrollOffset * 1.0 / width)).toInt()
ScrollOrientation.LEFT_TO_RIGHT -> itemCount - 1 - Math.ceil((mScrollOffset * 1.0 / width)).toInt()
ScrollOrientation.BOTTOM_TO_TOP -> Math.floor((mScrollOffset * 1.0 / height)).toInt()
ScrollOrientation.TOP_TO_BOTTOM -> itemCount - 1 - Math.ceil((mScrollOffset * 1.0 / height)).toInt()
}
}
private fun getLastVisibleItemPosition(): Int {
val firstVisiblePosition = getFirstVisibleItemPosition()
return if (firstVisiblePosition + mVisibleItemCount > itemCount - 1) {
itemCount - 1
} else {
firstVisiblePosition + mVisibleItemCount
}
}
private fun getFirstVisibleItemMovePercent(): Float {
return when (mScrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT -> {
return if (width == 0) {
0f
} else {
(mScrollOffset % width) * 1.0f / width
}
}
ScrollOrientation.LEFT_TO_RIGHT -> {
if (width == 0) {
return 0f
}
val targetPercent = 1 - (mScrollOffset % width) * 1.0f / width
return if (targetPercent == 1f) {
0f
} else {
targetPercent
}
}
ScrollOrientation.BOTTOM_TO_TOP -> (mScrollOffset % height) * 1.0f / height
ScrollOrientation.TOP_TO_BOTTOM -> {
val targetPercent = 1 - (mScrollOffset % height) * 1.0f / height
return if (targetPercent == 1f) {
0f
} else {
targetPercent
}
}
}
}
private fun calculateCenterPosition(position: Int): Int {
//当是 Fling 触发的时候
val triggerOrientation = mFlingOrientation
mFlingOrientation = FlingOrientation.NONE
when(mScrollOrientation) {
ScrollOrientation.RIGHT_TO_LEFT -> {
if (triggerOrientation == FlingOrientation.RIGHT_TO_LEFT) {
return position + 1
} else if (triggerOrientation == FlingOrientation.LEFT_TO_RIGHT) {
return position
}
}
ScrollOrientation.LEFT_TO_RIGHT -> {
if (triggerOrientation == FlingOrientation.LEFT_TO_RIGHT) {
return position + 1
} else if (triggerOrientation == FlingOrientation.RIGHT_TO_LEFT) {
return position
}
}
ScrollOrientation.BOTTOM_TO_TOP -> {
if (triggerOrientation == FlingOrientation.BOTTOM_TO_TOP) {
return position + 1
} else if (triggerOrientation == FlingOrientation.TOP_TO_BOTTOM) {
return position
}
}
ScrollOrientation.TOP_TO_BOTTOM -> {
if (triggerOrientation == FlingOrientation.TOP_TO_BOTTOM) {
return position + 1
} else if (triggerOrientation == FlingOrientation.BOTTOM_TO_TOP) {
return position
}
}
}
//当不是 fling 触发的时候
val percent = getFirstVisibleItemMovePercent()
//向左移动超过50% position(firstVisibleItemPosition)++
//否 position不变
return if (percent < 0.5) {
position
} else {
position + 1
}
}
}

View File

@ -0,0 +1,3 @@
<resources>
<string name="app_name">StackLayoutManager</string>
</resources>

View File

@ -0,0 +1,17 @@
package com.littlemango.stacklayoutmanager;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

27
build.gradle Normal file
View File

@ -0,0 +1,27 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

13
gradle.properties Normal file
View File

@ -0,0 +1,13 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Thu Jun 28 17:28:50 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

172
gradlew vendored Executable file
View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View File

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

BIN
sample/.DS_Store vendored Normal file

Binary file not shown.

1
sample/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

40
sample/build.gradle Normal file
View File

@ -0,0 +1,40 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.littlemango.stacklayoutmanagermaster"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext.kotlin_version = '1.2.50'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation project(':StackLayoutManager')
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
implementation 'com.android.support:design:27.1.1'
}

21
sample/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# 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 *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

BIN
sample/src/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,24 @@
package com.littlemango.stacklayoutmanagermaster
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("com.littlemango.stacklayoutmanagermaster", appContext.packageName)
}
}

BIN
sample/src/main/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.littlemango.stacklayoutmanagermaster">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,30 @@
package com.littlemango.stacklayoutmanagermaster;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import com.littlemango.stacklayoutmanager.StackAnimation;
import com.littlemango.stacklayoutmanager.StackLayoutManager.ScrollOrientation;
import org.jetbrains.annotations.NotNull;
public class FadeInFadeOutAnimation extends StackAnimation {
private int mVisibleCount;
FadeInFadeOutAnimation(@NotNull ScrollOrientation scrollOrientation, int visibleCount) {
super(scrollOrientation, visibleCount);
mVisibleCount = visibleCount;
}
@Override
public void doAnimation(float firstMovePercent, @NotNull View itemView, int position) {
if (position == 0) {
itemView.setAlpha(1 - firstMovePercent + 0.5f);
} else if (position == mVisibleCount) {
itemView.setAlpha(firstMovePercent);
}
itemView.setScaleX(1);
itemView.setScaleY(1);
}
}

View File

@ -0,0 +1,174 @@
package com.littlemango.stacklayoutmanagermaster;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.afollestad.materialdialogs.MaterialDialog;
import com.littlemango.stacklayoutmanager.StackLayoutManager;
import com.littlemango.stacklayoutmanager.StackLayoutManager.ScrollOrientation;
import java.util.Random;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private RecyclerView mRecyclerView;
private static final int mStackCount = 30;
private int mRandomPosition;
private StackLayoutManager mStackLayoutManager;
private String[] selectItems;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = findViewById(R.id.recycleView);
mStackLayoutManager = new StackLayoutManager();
mRecyclerView.setLayoutManager(mStackLayoutManager);
mRecyclerView.setAdapter(new StackLayoutAdapter());
selectItems = getResources().getStringArray(R.array.items);
resetRandom();
findViewById(R.id.floatButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new MaterialDialog.Builder(MainActivity.this)
.items(selectItems)
.itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
switch (which) {
case 0:
mRecyclerView.smoothScrollToPosition(mRandomPosition);
resetRandom();
break;
case 1:
mRecyclerView.scrollToPosition(mRandomPosition);
resetRandom();
break;
case 2:
mStackLayoutManager = new StackLayoutManager(ScrollOrientation.LEFT_TO_RIGHT);
mRecyclerView.setLayoutManager(mStackLayoutManager);
break;
case 3:
mStackLayoutManager = new StackLayoutManager(ScrollOrientation.RIGHT_TO_LEFT);
mRecyclerView.setLayoutManager(mStackLayoutManager);
break;
case 4:
mStackLayoutManager = new StackLayoutManager(ScrollOrientation.TOP_TO_BOTTOM);
mRecyclerView.setLayoutManager(mStackLayoutManager);
break;
case 5:
mStackLayoutManager = new StackLayoutManager(ScrollOrientation.BOTTOM_TO_TOP);
mRecyclerView.setLayoutManager(mStackLayoutManager);
break;
case 6:
mStackLayoutManager.setPagerMode(!mStackLayoutManager.getPagerMode());
break;
case 7:
mStackLayoutManager.setItemOffset(mStackLayoutManager.getItemOffset() + 10);
mStackLayoutManager.requestLayout();
break;
case 8:
mStackLayoutManager.setItemOffset(mStackLayoutManager.getItemOffset() - 10);
mStackLayoutManager.requestLayout();
break;
case 9:
mStackLayoutManager.setVisibleItemCount(mStackLayoutManager.getVisibleItemCount() + 1);
mStackLayoutManager.requestLayout();
break;
case 10:
mStackLayoutManager.setVisibleItemCount(mStackLayoutManager.getVisibleItemCount() - 1);
mStackLayoutManager.requestLayout();
break;
case 11:
mStackLayoutManager.setPagerFlingVelocity(mStackLayoutManager.getPagerFlingVelocity() + 5000);
break;
case 12:
mStackLayoutManager.setPagerFlingVelocity(mStackLayoutManager.getPagerFlingVelocity() - 5000);
break;
case 13:
mStackLayoutManager.setAnimation(new FadeInFadeOutAnimation(mStackLayoutManager.getScrollOrientation(),
mStackLayoutManager.getVisibleItemCount()));
mStackLayoutManager.requestLayout();
break;
}
}
})
.show();
}
});
}
class StackLayoutAdapter extends RecyclerView.Adapter<StackLayoutAdapter.StackHolder> {
@NonNull
@Override
public StackHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.image_card, viewGroup, false);
return new StackHolder(view);
}
@Override
public void onBindViewHolder(@NonNull StackHolder stackHolder, int position) {
int res;
switch (position % 6) {
case 0:
res = R.drawable.image1;
break;
case 1:
res = R.drawable.image2;
break;
case 2:
res = R.drawable.image3;
break;
case 3:
res = R.drawable.image4;
break;
case 4:
res = R.drawable.image5;
break;
default:
res = R.drawable.image6;
break;
}
stackHolder.imageView.setImageResource(res);
stackHolder.textView.setText("" + position);
}
@Override
public int getItemCount() {
return mStackCount;
}
class StackHolder extends RecyclerView.ViewHolder {
ImageView imageView;
TextView textView;
StackHolder(@NonNull View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.imageView);
textView = itemView.findViewById(R.id.textView);
}
}
}
private void resetRandom() {
mRandomPosition = Math.abs(new Random().nextInt() % mStackCount);
selectItems[0] = getResources().getString(R.string.smooth_scroll) + mRandomPosition;
selectItems[1] = getResources().getString(R.string.scroll) + mRandomPosition;
}
}

BIN
sample/src/main/res/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycleView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
app:fabSize="normal"
android:src="@drawable/ic_star_black_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="270dp"
android:layout_height="400dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardElevation="4dp"
app:cardCornerRadius="10dp"
>
<ImageView
android:id="@+id/imageView"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ImageView>
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="50sp"/>
</android.support.v7.widget.CardView>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="items">
<item> </item>
<item> </item>
<item>卡片从左到右移出</item>
<item>卡片从右到左移出</item>
<item>卡片从上到下移出</item>
<item>卡片从下到上移出</item>
<item>改变PageMode</item>
<item>增加每个item之间的偏移</item>
<item>减少每个item之间的偏移</item>
<item>增加可见item的数量</item>
<item>减少可见item的数量</item>
<item>增加PageMode=true时的滑动阻尼</item>
<item>减少PageMode=true时的滑动阻尼</item>
<item>自定义动画</item>
</string-array>
</resources>

View File

@ -0,0 +1,5 @@
<resources>
<string name="app_name">StackLayoutManagerMaster</string>
<string name="smooth_scroll">带动画滚动到指定位置 </string>
<string name="scroll">不带动画滚动到指定位置 </string>
</resources>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="items">
<item> </item>
<item> </item>
<item>From Right To Left</item>
<item>From Left To Right</item>
<item>From Top To Bottom</item>
<item>From Bottom To Top</item>
<item>Change PageMode</item>
<item>Increase item offset</item>
<item>Decrease item offset</item>
<item>Increase visible itemCount</item>
<item>Decrease visible itemCount</item>
<item>Increase fling damp</item>
<item>Decrease fling damp</item>
<item>Use custom animation</item>
</string-array>
</resources>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>

View File

@ -0,0 +1,5 @@
<resources>
<string name="app_name">StackLayoutManagerMaster</string>
<string name="smooth_scroll">smoothScroll to </string>
<string name="scroll">scroll to </string>
</resources>

View File

@ -0,0 +1,11 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>

View File

@ -0,0 +1,17 @@
package com.littlemango.stacklayoutmanagermaster
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

1
settings.gradle Normal file
View File

@ -0,0 +1 @@
include ':sample', ':StackLayoutManager'