├── .gitignore ├── .idea ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── renny │ │ └── contractgridview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── renny │ │ │ └── contractgridview │ │ │ ├── BottomDialogFragment.java │ │ │ ├── HorizontalActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── OverlyingView.java │ │ │ ├── Vertial2Activity.java │ │ │ ├── VertialActivity.java │ │ │ └── recyclerview │ │ │ ├── ItemAdapter.java │ │ │ ├── ItemAdapterHor.java │ │ │ └── OverFlyingLayoutManager.java │ └── res │ │ ├── anim │ │ ├── dialog_enter.xml │ │ └── dialog_out.xml │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable-xxhdpi │ │ ├── ie.png │ │ ├── ie_select.png │ │ ├── qq.png │ │ ├── qq_select.png │ │ ├── sogo.png │ │ └── sogo_select.png │ │ ├── drawable │ │ ├── background.xml │ │ ├── bg_ie.xml │ │ ├── bg_qq.xml │ │ ├── bg_sogo.xml │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_horizontal.xml │ │ ├── activity_main.xml │ │ ├── activity_vertial.xml │ │ ├── activity_vertial2.xml │ │ ├── fragment_bottom.xml │ │ ├── item_card.xml │ │ └── item_card_hor.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 │ └── renny │ └── contractgridview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── image ├── gif.gif ├── hor.gif └── ver.gif └── 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/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 34 | 35 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 83 | 93 | 94 | 95 | 96 | 97 | 98 | 100 | 101 | 102 | 103 | 104 | 1.8 105 | 106 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 仿夸克主页底部层叠弹框+仿Android系统通知栏层叠列表 2 | 3 | 注意:请保证层叠列表的每项尺寸都相同,不然会出现显示错位的问题。 4 | 5 | * 博客地址:[仿夸克主页底部工具栏](https://juejin.im/post/5a2a05dc6fb9a045030ffe97) 6 | 7 | * 博客地址:[层叠列表](https://juejin.im/post/5a2f8c476fb9a0450b665b11) 8 | 9 | ![](image/gif.gif) 10 | ![](image/ver.gif) 11 | ![](image/hor.gif) 12 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.renny.contractgridview" 7 | minSdkVersion 17 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:26.1.0' 24 | 25 | compile 'com.android.support:recyclerview-v7:26.1.0' 26 | compile 'com.android.support:cardview-v7:26.1.0' 27 | 28 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 29 | testImplementation 'junit:junit:4.12' 30 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 31 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 32 | } 33 | -------------------------------------------------------------------------------- /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/renny/contractgridview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview; 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() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.renny.contractgridview", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/BottomDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview; 2 | 3 | import android.app.Dialog; 4 | import android.graphics.Color; 5 | import android.graphics.drawable.ColorDrawable; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v4.app.DialogFragment; 9 | import android.view.Gravity; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.view.Window; 14 | import android.widget.Toast; 15 | 16 | import static android.widget.Toast.LENGTH_SHORT; 17 | 18 | /** 19 | * Created by Renny on 2017/12/8. 20 | */ 21 | 22 | public class BottomDialogFragment extends DialogFragment implements View.OnClickListener { 23 | 24 | 25 | @Override 26 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 27 | return inflater.inflate(R.layout.fragment_bottom, null); 28 | } 29 | 30 | @Override 31 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 32 | view.findViewById(R.id.sogo1).setOnClickListener(this); 33 | view.findViewById(R.id.sogo2).setOnClickListener(this); 34 | view.findViewById(R.id.sogo3).setOnClickListener(this); 35 | view.findViewById(R.id.qq1).setOnClickListener(this); 36 | view.findViewById(R.id.qq2).setOnClickListener(this); 37 | view.findViewById(R.id.qq3).setOnClickListener(this); 38 | view.findViewById(R.id.ie1).setOnClickListener(this); 39 | view.findViewById(R.id.ie2).setOnClickListener(this); 40 | view.findViewById(R.id.ie3).setOnClickListener(this); 41 | } 42 | 43 | public void onStart() { 44 | super.onStart(); 45 | Dialog dialog = getDialog(); 46 | if (dialog != null && dialog.getWindow() != null) { 47 | Window window = dialog.getWindow(); 48 | dialog.getWindow().setGravity(Gravity.BOTTOM); 49 | dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 50 | window.setWindowAnimations(R.style.animate_dialog); 51 | window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 52 | setCancelable(true); 53 | } 54 | } 55 | 56 | @Override 57 | public void onClick(View v) { 58 | v.setSelected(!v.isSelected()); 59 | int id = v.getId(); 60 | switch (id) { 61 | case R.id.sogo1: 62 | case R.id.sogo2: 63 | case R.id.sogo3: 64 | Toast.makeText(getActivity(), "SoGO", LENGTH_SHORT).show(); 65 | break; 66 | case R.id.qq1: 67 | case R.id.qq2: 68 | case R.id.qq3: 69 | Toast.makeText(getActivity(), "QQ", LENGTH_SHORT).show(); 70 | break; 71 | case R.id.ie1: 72 | case R.id.ie2: 73 | case R.id.ie3: 74 | Toast.makeText(getActivity(), "IE", LENGTH_SHORT).show(); 75 | break; 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/HorizontalActivity.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.OrientationHelper; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.View; 8 | 9 | import com.renny.contractgridview.recyclerview.ItemAdapterHor; 10 | import com.renny.contractgridview.recyclerview.OverFlyingLayoutManager; 11 | 12 | import java.util.ArrayList; 13 | 14 | public class HorizontalActivity extends AppCompatActivity { 15 | private RecyclerView mRecyclerView, mRecyclerView2; 16 | private ArrayList items = new ArrayList<>(); 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_horizontal); 22 | initView(); 23 | } 24 | 25 | OverFlyingLayoutManager layoutManager, layoutManager2; 26 | 27 | private void initView() { 28 | mRecyclerView = findViewById(R.id.recyclerView); 29 | mRecyclerView2 = findViewById(R.id.recyclerView2); 30 | 31 | layoutManager = new OverFlyingLayoutManager(OrientationHelper.HORIZONTAL); 32 | mRecyclerView.setLayoutManager(layoutManager); 33 | 34 | layoutManager2 = new OverFlyingLayoutManager(OrientationHelper.HORIZONTAL, false); 35 | mRecyclerView2.setLayoutManager(layoutManager2); 36 | 37 | //构建一个临时数据源 38 | for (int i = 0; i < 216; i++) { 39 | items.add("Item:第" + i + "项"); 40 | } 41 | ItemAdapterHor adapter = new ItemAdapterHor(items); 42 | mRecyclerView.setAdapter(adapter); 43 | adapter.setOnItemClickListerer(new ItemAdapterHor.onItemClickListener() { 44 | @Override 45 | public void onItemClick(View view, int position) { 46 | // Toast.makeText(HorizontalActivity.this, "position:" + position, Toast.LENGTH_SHORT).show(); 47 | } 48 | }); 49 | 50 | ItemAdapterHor adapter2 = new ItemAdapterHor(items); 51 | mRecyclerView2.setAdapter(adapter2); 52 | adapter2.setOnItemClickListerer(new ItemAdapterHor.onItemClickListener() { 53 | @Override 54 | public void onItemClick(View view, int position) { 55 | // Toast.makeText(HorizontalActivity.this, "position:" + position, Toast.LENGTH_SHORT).show(); 56 | } 57 | }); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | 9 | public class MainActivity extends AppCompatActivity { 10 | 11 | 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | 18 | } 19 | 20 | 21 | /** 22 | * 显示底部Dialog 23 | */ 24 | public void showBottomDialog(View view) { 25 | FragmentManager fm = getSupportFragmentManager(); 26 | BottomDialogFragment bottomDialogFragment = new BottomDialogFragment(); 27 | bottomDialogFragment.show(fm, "fragment_bottom_dialog"); 28 | } 29 | 30 | public void goVer(View view) { 31 | startActivity(new Intent(MainActivity.this, VertialActivity.class)); 32 | } 33 | 34 | public void goHor(View view) { 35 | startActivity(new Intent(MainActivity.this, HorizontalActivity.class)); 36 | } 37 | 38 | public void goVerSingle(View view) { 39 | startActivity(new Intent(MainActivity.this, Vertial2Activity.class)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/OverlyingView.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview; 2 | 3 | import android.content.Context; 4 | import android.os.Build; 5 | import android.support.annotation.NonNull; 6 | import android.support.annotation.Nullable; 7 | import android.support.v4.widget.ViewDragHelper; 8 | import android.util.AttributeSet; 9 | import android.util.Log; 10 | import android.view.MotionEvent; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | 14 | /** 15 | * Created by Renny on 2017/12/7. 16 | */ 17 | 18 | public class OverlyingView extends ViewGroup { 19 | 20 | private ViewDragHelper mDragger; 21 | private View topView, bottomView; 22 | private openChangeListener mOpenChangeListener; 23 | private int elevationHeight = 25;//层叠高度 24 | private int extendHeight = 30;//延伸高度 25 | private boolean isExpand = true; 26 | 27 | public OverlyingView(@NonNull Context context) { 28 | this(context, null); 29 | } 30 | 31 | public OverlyingView(@NonNull Context context, @Nullable AttributeSet attrs) { 32 | this(context, attrs, 0); 33 | } 34 | 35 | public OverlyingView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 36 | super(context, attrs, defStyleAttr); 37 | } 38 | 39 | @Override 40 | protected void onFinishInflate() { 41 | super.onFinishInflate(); 42 | if (getChildCount() != 2) { 43 | throw new RuntimeException("必须有2个View!"); 44 | } 45 | if (mDragger == null) { 46 | topView = getChildAt(0); 47 | bottomView = getChildAt(1); 48 | bringChildToFront(topView); 49 | mDragger = ViewDragHelper.create(this, 1.0f, new ViewDragHelperCallBack()); 50 | } 51 | } 52 | 53 | //折叠布局 54 | public void foldLayout() { 55 | if (topView != null && mDragger != null) { 56 | isExpand = false; 57 | mDragger.settleCapturedViewAt(topView.getLeft(), getHeight() - topView.getHeight() - elevationHeight); 58 | } 59 | } 60 | 61 | //还原/展开布局 62 | public void expandLayout() { 63 | if (topView != null && mDragger != null) { 64 | mDragger.settleCapturedViewAt(topView.getLeft(), 0); 65 | isExpand = true; 66 | } 67 | } 68 | 69 | //布局是否展开状态 70 | public boolean isExpand() { 71 | return isExpand; 72 | } 73 | 74 | private class ViewDragHelperCallBack extends ViewDragHelper.Callback { 75 | @Override 76 | public boolean tryCaptureView(View child, int pointerId) { 77 | return topView == child; 78 | } 79 | 80 | @Override 81 | public int clampViewPositionHorizontal(View child, int left, int dx) { 82 | return 0; 83 | } 84 | 85 | @Override 86 | public int getViewVerticalDragRange(View child) { 87 | return 1; 88 | } 89 | 90 | @Override 91 | public int clampViewPositionVertical(View child, int top, int dy) { 92 | final int topBound = getPaddingTop(); 93 | final int bottomBound = getHeight() - child.getHeight() - getPaddingBottom() - elevationHeight; 94 | return Math.min(Math.max(top, topBound), bottomBound); 95 | } 96 | 97 | @Override 98 | public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) { 99 | float percent = (float) top / (getHeight() - changedView.getHeight() - elevationHeight); 100 | Log.d("OverlyingView", "percent" + percent); 101 | if (mOpenChangeListener != null) { 102 | mOpenChangeListener.onScrolling(percent); 103 | } 104 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 105 | changedView.setElevation(percent * 10); 106 | } 107 | bottomView.setScaleX(1 - percent * 0.03f); 108 | } 109 | 110 | @Override 111 | public void onViewReleased(View releasedChild, float xvel, float yvel) { 112 | if (releasedChild == topView) { 113 | float movePercentage = (float) (releasedChild.getTop()) / (getHeight() - releasedChild.getHeight() - elevationHeight); 114 | int finalTop = (movePercentage >= .5f) ? getHeight() - releasedChild.getHeight() - elevationHeight : 0; 115 | mDragger.settleCapturedViewAt(releasedChild.getLeft(), finalTop); 116 | isExpand = movePercentage < .5f; 117 | invalidate(); 118 | } 119 | } 120 | } 121 | 122 | @Override 123 | public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { 124 | return new MarginLayoutParams(getContext(), attrs); 125 | } 126 | 127 | @Override 128 | public void computeScroll() { 129 | if (mDragger.continueSettling(true)) { 130 | invalidate(); 131 | } 132 | } 133 | 134 | @Override 135 | public boolean onInterceptTouchEvent(MotionEvent event) { 136 | return mDragger.shouldInterceptTouchEvent(event); 137 | } 138 | 139 | @Override 140 | public boolean onTouchEvent(MotionEvent event) { 141 | mDragger.processTouchEvent(event); 142 | return true; 143 | } 144 | 145 | /** 146 | * 计算所有ChildView的宽度和高度 然后根据ChildView的计算结果,设置自己的宽和高 147 | */ 148 | @Override 149 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 150 | 151 | // 获得此ViewGroup上级容器为其推荐的宽和高,以及计算模式 152 | int widthMode = MeasureSpec.getMode(widthMeasureSpec); 153 | int heightMode = MeasureSpec.getMode(heightMeasureSpec); 154 | int sizeWidth = MeasureSpec.getSize(widthMeasureSpec); 155 | int sizeHeight = MeasureSpec.getSize(heightMeasureSpec); 156 | 157 | // 计算出所有的childView的宽和高 158 | measureChildren(widthMeasureSpec, heightMeasureSpec); 159 | 160 | int width = 0; 161 | int height = 0; 162 | 163 | 164 | // 根据childView计算的出的宽和高,以及设置的margin计算容器的宽和高,主要用于容器是warp_content时 165 | 166 | for (int i = 0; i < getChildCount(); i++) { 167 | View childView = getChildAt(i); 168 | MarginLayoutParams cParams = (MarginLayoutParams) childView.getLayoutParams(); 169 | int cWidthWithMargin = childView.getMeasuredWidth() + cParams.leftMargin + cParams.rightMargin; 170 | int cHeightWithMargin = childView.getMeasuredHeight() + cParams.topMargin + cParams.bottomMargin; 171 | 172 | height = height + cHeightWithMargin; 173 | width = cWidthWithMargin > width ? cWidthWithMargin : width; 174 | } 175 | 176 | // 如果是wrap_content设置为我们计算的值,否则:直接设置为父容器计算的值 177 | setMeasuredDimension((widthMode == MeasureSpec.EXACTLY) ? sizeWidth 178 | : width, (heightMode == MeasureSpec.EXACTLY) ? sizeHeight 179 | : height); 180 | } 181 | 182 | @Override 183 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 184 | /** 185 | * 遍历所有childView根据其宽和高,以及margin进行布局 186 | */ 187 | for (int i = 0; i < getChildCount(); i++) { 188 | View childView = getChildAt(i); 189 | int cWidth = childView.getMeasuredWidth(); 190 | int cHeight = childView.getMeasuredHeight(); 191 | MarginLayoutParams cParams = (MarginLayoutParams) childView.getLayoutParams(); 192 | int cl = 0, ct = 0, cr = 0, cb = 0; 193 | switch (i) { 194 | case 0: 195 | cl = cParams.leftMargin; 196 | ct = getHeight() - cHeight - cParams.bottomMargin - extendHeight; 197 | cb = cHeight + ct + extendHeight; 198 | childView.setPadding(0, extendHeight, 0, 0); 199 | cr = cl + cWidth; 200 | break; 201 | case 1: 202 | cl = cParams.leftMargin; 203 | ct = cParams.topMargin; 204 | cb = cHeight + ct; 205 | cr = cl + cWidth; 206 | break; 207 | } 208 | childView.layout(cl, ct, cr, cb); 209 | } 210 | } 211 | 212 | public void setExtendHeight(int extendHeight) { 213 | this.extendHeight = extendHeight; 214 | requestLayout(); 215 | } 216 | 217 | public void setOpenChangeListener(openChangeListener openChangeListener) { 218 | mOpenChangeListener = openChangeListener; 219 | } 220 | 221 | public void setElevationHeight(int elevationHeight) { 222 | this.elevationHeight = elevationHeight; 223 | requestLayout(); 224 | } 225 | 226 | public interface openChangeListener { 227 | 228 | void onScrolling(float percent); 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/Vertial2Activity.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.OrientationHelper; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.View; 8 | import android.widget.Toast; 9 | 10 | import com.renny.contractgridview.recyclerview.ItemAdapter; 11 | import com.renny.contractgridview.recyclerview.OverFlyingLayoutManager; 12 | 13 | import java.util.ArrayList; 14 | 15 | public class Vertial2Activity extends AppCompatActivity { 16 | private RecyclerView mRecyclerView; 17 | private ItemAdapter mAdapter; 18 | private ArrayList items = new ArrayList<>(); 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_vertial); 25 | initView(); 26 | } 27 | 28 | private void initView() { 29 | mRecyclerView = findViewById(R.id.recyclerView); 30 | OverFlyingLayoutManager layoutManager = new OverFlyingLayoutManager(OrientationHelper.VERTICAL, false); 31 | mRecyclerView.setLayoutManager(layoutManager); 32 | 33 | //构建一个临时数据源 34 | for (int i = 0; i < 126; i++) { 35 | items.add("Item:第" + i + "项"); 36 | } 37 | mAdapter = new ItemAdapter(items); 38 | mRecyclerView.setAdapter(mAdapter); 39 | mAdapter.setOnItemClickListerer(new ItemAdapter.onItemClickListener() { 40 | @Override 41 | public void onItemClick(View view) { 42 | Toast.makeText(Vertial2Activity.this, "", Toast.LENGTH_SHORT).show(); 43 | } 44 | }); 45 | } 46 | } -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/VertialActivity.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.OrientationHelper; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.View; 8 | import android.widget.Toast; 9 | 10 | import com.renny.contractgridview.recyclerview.ItemAdapter; 11 | import com.renny.contractgridview.recyclerview.OverFlyingLayoutManager; 12 | 13 | import java.util.ArrayList; 14 | 15 | public class VertialActivity extends AppCompatActivity { 16 | private RecyclerView mRecyclerView; 17 | private ItemAdapter mAdapter; 18 | private ArrayList items = new ArrayList<>(); 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_vertial); 24 | initView(); 25 | } 26 | 27 | private void initView() { 28 | mRecyclerView = findViewById(R.id.recyclerView); 29 | OverFlyingLayoutManager layoutManager = new OverFlyingLayoutManager(OrientationHelper.VERTICAL,true); 30 | mRecyclerView.setLayoutManager(layoutManager); 31 | 32 | //构建一个临时数据源 33 | for (int i = 0; i < 1126; i++) { 34 | items.add("Item:第" + i + "项"); 35 | } 36 | mAdapter = new ItemAdapter(items); 37 | mRecyclerView.setAdapter(mAdapter); 38 | mAdapter.setOnItemClickListerer(new ItemAdapter.onItemClickListener() { 39 | @Override 40 | public void onItemClick(View view) { 41 | Toast.makeText(VertialActivity.this, "", Toast.LENGTH_SHORT).show(); 42 | } 43 | }); 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/recyclerview/ItemAdapter.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview.recyclerview; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | 9 | import com.renny.contractgridview.R; 10 | 11 | import java.util.ArrayList; 12 | 13 | /** 14 | * Created by LuckyCrystal on 2017/6/6. 15 | */ 16 | 17 | public class ItemAdapter extends RecyclerView.Adapter { 18 | 19 | private ArrayList items = new ArrayList<>(); 20 | private onItemClickListener mOnItemClickListerer; 21 | 22 | public ItemAdapter(ArrayList items) { 23 | this.items = items; 24 | } 25 | 26 | public void setOnItemClickListerer(onItemClickListener onItemClickListerer) { 27 | mOnItemClickListerer = onItemClickListerer; 28 | } 29 | 30 | @Override 31 | public viewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { 32 | View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_card, 33 | viewGroup, false); 34 | if (mOnItemClickListerer != null) { 35 | view.setOnClickListener(new View.OnClickListener() { 36 | @Override 37 | public void onClick(View v) { 38 | mOnItemClickListerer.onItemClick(v); 39 | } 40 | }); 41 | } 42 | return new viewHolder(view); 43 | } 44 | 45 | @Override 46 | public int getItemViewType(int position) { 47 | return super.getItemViewType(position); 48 | } 49 | 50 | @Override 51 | public void onBindViewHolder(viewHolder viewHolder, int position) { 52 | String info = items.get(position); 53 | viewHolder.textView.setText(info); 54 | } 55 | 56 | 57 | @Override 58 | public int getItemCount() { 59 | return items.size(); 60 | } 61 | 62 | class viewHolder extends RecyclerView.ViewHolder { 63 | TextView textView; 64 | 65 | public viewHolder(View itemView) { 66 | super(itemView); 67 | textView = itemView.findViewById(R.id.info_text); 68 | } 69 | } 70 | 71 | public interface onItemClickListener { 72 | void onItemClick(View view); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/recyclerview/ItemAdapterHor.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview.recyclerview; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | 9 | import com.renny.contractgridview.R; 10 | 11 | import java.util.ArrayList; 12 | 13 | /** 14 | * Created by LuckyCrystal on 2017/6/6. 15 | */ 16 | 17 | public class ItemAdapterHor extends RecyclerView.Adapter { 18 | 19 | private ArrayList items = new ArrayList<>(); 20 | private onItemClickListener mOnItemClickListerer; 21 | 22 | 23 | public ItemAdapterHor(ArrayList items) { 24 | this.items = items; 25 | } 26 | 27 | public void setOnItemClickListerer(onItemClickListener onItemClickListerer) { 28 | mOnItemClickListerer = onItemClickListerer; 29 | } 30 | 31 | @Override 32 | public viewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { 33 | View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_card_hor, 34 | viewGroup, false); 35 | 36 | return new viewHolder(view); 37 | } 38 | 39 | @Override 40 | public int getItemViewType(int position) { 41 | return super.getItemViewType(position); 42 | } 43 | 44 | @Override 45 | public void onBindViewHolder(final viewHolder viewHolder, final int position) { 46 | String info = items.get(position); 47 | viewHolder.textView.setText(info); 48 | if (mOnItemClickListerer != null) { 49 | viewHolder.itemView.setOnClickListener(new View.OnClickListener() { 50 | @Override 51 | public void onClick(View v) { 52 | mOnItemClickListerer.onItemClick(viewHolder.itemView, position); 53 | } 54 | }); 55 | } 56 | } 57 | 58 | @Override 59 | public int getItemCount() { 60 | return items.size(); 61 | } 62 | 63 | class viewHolder extends RecyclerView.ViewHolder { 64 | TextView textView; 65 | 66 | public viewHolder(View itemView) { 67 | super(itemView); 68 | textView = itemView.findViewById(R.id.info_text_hor); 69 | } 70 | } 71 | 72 | public interface onItemClickListener { 73 | void onItemClick(View view, int position); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/renny/contractgridview/recyclerview/OverFlyingLayoutManager.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview.recyclerview; 2 | 3 | import android.graphics.Rect; 4 | import android.support.annotation.FloatRange; 5 | import android.support.annotation.IntRange; 6 | import android.support.v7.widget.OrientationHelper; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.util.Log; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | /** 13 | * Created by LuckyCrystal on 2017/6/6. 14 | */ 15 | 16 | public class OverFlyingLayoutManager extends RecyclerView.LayoutManager { 17 | 18 | private static final String TAG = "OverFlying"; 19 | 20 | private @FloatRange(from = 0.01, to = 1.0) 21 | float edgePercent = 0.8f;//触发边缘动画距离百分比 22 | 23 | private @FloatRange(from = 1) 24 | float slowTimes = 3;//到达此距离后放慢倍数 25 | 26 | private int orientation = OrientationHelper.VERTICAL; 27 | private boolean offsetUseful = false; 28 | private int overFlyingDist; 29 | private int totalHeight = 0; 30 | private int totalWidth = 0; 31 | private int verticalScrollOffset; 32 | private int horizontalScrollOffset; 33 | //头部是否也要层叠,默认需要 34 | private boolean topOverFlying; 35 | private int viewWidth, viewHeight; 36 | 37 | public OverFlyingLayoutManager() { 38 | this(OrientationHelper.VERTICAL); 39 | } 40 | 41 | public OverFlyingLayoutManager(int orientation) { 42 | this(orientation, true); 43 | } 44 | 45 | public OverFlyingLayoutManager(int orientation, boolean topOverFlying) { 46 | this.orientation = orientation; 47 | this.topOverFlying = topOverFlying; 48 | } 49 | 50 | 51 | @Override 52 | public RecyclerView.LayoutParams generateDefaultLayoutParams() { 53 | return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 54 | ViewGroup.LayoutParams.WRAP_CONTENT); 55 | } 56 | 57 | @Override 58 | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { 59 | super.onLayoutChildren(recycler, state); 60 | // 先把所有的View先从RecyclerView中detach掉,然后标记为"Scrap"状态,表示这些View处于可被重用状态(非显示中)。 61 | // 实际就是把View放到了Recycler中的一个集合中。 62 | if (getItemCount() == 0) {//没有Item 63 | detachAndScrapAttachedViews(recycler); 64 | return; 65 | } 66 | if (getChildCount() == 0 && state.isPreLayout()) { 67 | return; 68 | } 69 | reset(); 70 | detachAndScrapAttachedViews(recycler); 71 | calculateChildrenSite(recycler, state); 72 | } 73 | 74 | private void reset() { 75 | totalHeight = 0; 76 | totalWidth = 0; 77 | if (!offsetUseful) { 78 | verticalScrollOffset = 0; 79 | horizontalScrollOffset = 0; 80 | } 81 | offsetUseful = false; 82 | } 83 | 84 | private void calculateChildrenSite(RecyclerView.Recycler recycler, RecyclerView.State state) { 85 | if (orientation == OrientationHelper.VERTICAL) { 86 | calculateChildrenSiteVertical(recycler, state); 87 | addAndLayoutViewVertical(recycler, state, verticalScrollOffset); 88 | } else { 89 | calculateChildrenSiteHorizontal(recycler, state); 90 | addAndLayoutViewHorizontal(recycler, state, horizontalScrollOffset); 91 | } 92 | 93 | } 94 | 95 | private void calculateChildrenSiteVertical(RecyclerView.Recycler recycler, RecyclerView.State state) { 96 | View view = recycler.getViewForPosition(0);//暂时这么解决,不能layout出所有的子View 97 | measureChildWithMargins(view, 0, 0); 98 | calculateItemDecorationsForChild(view, new Rect()); 99 | 100 | viewHeight = getDecoratedMeasuredHeight(view); 101 | overFlyingDist = (int) (slowTimes * viewHeight); 102 | totalHeight = getItemCount() * viewHeight; 103 | Log.d(TAG, "childCountI = " + getChildCount() + " itemCount= " + recycler.getScrapList().size()); 104 | 105 | } 106 | 107 | 108 | private void calculateChildrenSiteHorizontal(RecyclerView.Recycler recycler, RecyclerView.State state) { 109 | View view = recycler.getViewForPosition(0);//暂时这么解决,不能layout出所有的子View 110 | measureChildWithMargins(view, 0, 0); 111 | calculateItemDecorationsForChild(view, new Rect()); 112 | viewWidth = getDecoratedMeasuredWidth(view); 113 | overFlyingDist = (int) (slowTimes * viewWidth); 114 | totalWidth = getItemCount() * viewWidth; 115 | Log.d(TAG, "childCountI = " + getChildCount() + " itemCount= " + recycler.getScrapList().size()); 116 | } 117 | 118 | @Override 119 | public boolean canScrollHorizontally() { 120 | // 返回true表示可以横向滑动 121 | return orientation == OrientationHelper.HORIZONTAL; 122 | } 123 | 124 | @Override 125 | public boolean canScrollVertically() { 126 | // 返回true表示可以纵向滑动 127 | return orientation == OrientationHelper.VERTICAL; 128 | } 129 | 130 | @Override 131 | public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) { 132 | //列表向下滚动dy为正,列表向上滚动dy为负,这点与Android坐标系保持一致。 133 | int tempDy = dy; 134 | if (verticalScrollOffset <= totalHeight - getVerticalSpace()) { 135 | verticalScrollOffset += dy; 136 | //将竖直方向的偏移量+travel 137 | } 138 | if (verticalScrollOffset > totalHeight - getVerticalSpace()) { 139 | verticalScrollOffset = totalHeight - getVerticalSpace(); 140 | tempDy = 0; 141 | } else if (verticalScrollOffset < 0) { 142 | verticalScrollOffset = 0; 143 | tempDy = 0; 144 | } 145 | detachAndScrapAttachedViews(recycler); 146 | addAndLayoutViewVertical(recycler, state, verticalScrollOffset); //从新布局位置、显示View 147 | return tempDy; 148 | } 149 | 150 | @Override 151 | public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) { 152 | 153 | int tempDx = dx; 154 | if (horizontalScrollOffset <= totalWidth - getHorizontalSpace()) { 155 | horizontalScrollOffset += dx; 156 | //将竖直方向的偏移量+travel 157 | } 158 | if (horizontalScrollOffset > totalWidth - getHorizontalSpace()) { 159 | horizontalScrollOffset = totalWidth - getHorizontalSpace(); 160 | tempDx = 0; 161 | } else if (horizontalScrollOffset < 0) { 162 | horizontalScrollOffset = 0; 163 | tempDx = 0; 164 | } 165 | detachAndScrapAttachedViews(recycler); 166 | addAndLayoutViewHorizontal(recycler, state, horizontalScrollOffset); //从新布局位置、显示View 167 | return tempDx; 168 | 169 | } 170 | 171 | private void addAndLayoutViewVertical(RecyclerView.Recycler recycler, RecyclerView.State state, int offset) { 172 | int itemCount = getItemCount(); 173 | if (itemCount <= 0 || state.isPreLayout()) { 174 | return; 175 | } 176 | int displayHeight = getVerticalSpace(); 177 | for (int i = itemCount - 1; i >= 0; i--) { 178 | 179 | // 遍历Recycler中保存的View取出来 180 | int bottomOffset = (i + 1) * viewHeight - offset; 181 | int topOffset = i * viewHeight - offset; 182 | boolean needAdd = true; 183 | if (bottomOffset - displayHeight >= overFlyingDist) { 184 | needAdd = false; 185 | } 186 | if (topOffset < -overFlyingDist && i != 0 && topOverFlying 187 | || topOffset < -overFlyingDist && !topOverFlying) { 188 | needAdd = false; 189 | } 190 | if (needAdd) { 191 | View view = recycler.getViewForPosition(i); 192 | addView(view); // 因为刚刚进行了detach操作,所以现在可以重新添加 193 | measureChildWithMargins(view, 0, 0); // 通知测量view的margin值 194 | int width = getDecoratedMeasuredWidth(view); // 计算view实际大小,包括了ItemDecorator中设置的偏移量。 195 | int height = getDecoratedMeasuredHeight(view); 196 | //调用这个方法能够调整ItemView的大小,以除去ItemDecorator。 197 | calculateItemDecorationsForChild(view, new Rect()); 198 | int realBottomOffset = bottomOffset; 199 | if (topOverFlying) { 200 | if (i != 0) {//除第一个外的顶部黏性动画 201 | if (topOffset <= height * edgePercent) {//到达顶部边界了 202 | int edgeDist = (int) (height * edgePercent);//边界触发距离 203 | int top = (int) (edgeDist - (edgeDist - topOffset) / slowTimes);//到达边界后速度放慢到原来5分之一 204 | 205 | top = Math.max(top, 0); 206 | realBottomOffset = top + height; 207 | } 208 | } else { 209 | realBottomOffset = height; 210 | } 211 | } 212 | if (i != itemCount - 1) {//除最后一个外的底部慢速动画 213 | if (displayHeight - bottomOffset <= height * edgePercent) { 214 | int edgeDist = (int) (displayHeight - height * edgePercent); 215 | int bottom = (int) (edgeDist + (bottomOffset - edgeDist) / slowTimes); 216 | bottom = Math.min(bottom, displayHeight); 217 | realBottomOffset = bottom; 218 | 219 | } 220 | } else { 221 | realBottomOffset = totalHeight > displayHeight ? displayHeight : totalHeight; 222 | } 223 | layoutDecoratedWithMargins(view, 0, realBottomOffset - height, width, realBottomOffset); 224 | } 225 | } 226 | 227 | Log.d(TAG, "childCount = " + getChildCount() + " itemCount= " + itemCount); 228 | } 229 | 230 | private void addAndLayoutViewHorizontal(RecyclerView.Recycler recycler, RecyclerView.State state, int offset) { 231 | int itemCount = getItemCount(); 232 | if (itemCount <= 0 || state.isPreLayout()) { 233 | return; 234 | } 235 | int displayWidth = getHorizontalSpace(); 236 | 237 | for (int i = itemCount - 1; i >= 0; i--) { 238 | int rightOffset = (i + 1) * viewWidth - offset; 239 | int leftOffset = i * viewWidth - offset; 240 | boolean needAdd = true; 241 | if (rightOffset - displayWidth >= overFlyingDist) { 242 | needAdd = false; 243 | } 244 | if (leftOffset < -overFlyingDist && i != 0 245 | || leftOffset < -overFlyingDist && !topOverFlying) { 246 | needAdd = false; 247 | } 248 | if (needAdd) { 249 | // 遍历Recycler中保存的View取出来 250 | View view = recycler.getViewForPosition(i); 251 | addView(view); // 因为刚刚进行了detach操作,所以现在可以重新添加 252 | measureChildWithMargins(view, 0, 0); // 通知测量view的margin值 253 | int width = getDecoratedMeasuredWidth(view); // 计算view实际大小,包括了ItemDecorator中设置的偏移量。 254 | int height = getDecoratedMeasuredHeight(view); 255 | 256 | 257 | //调用这个方法能够调整ItemView的大小,以除去ItemDecorator。 258 | calculateItemDecorationsForChild(view, new Rect()); 259 | 260 | int realRightOffset = rightOffset; 261 | if (topOverFlying) {//除第一个外的左边缘慢速动画 262 | if (i != 0) { 263 | if (leftOffset <= width * edgePercent) {//到达边界了 264 | int edgeDist = (int) (width * edgePercent);//边界触发距离 265 | int left = (int) (edgeDist - (edgeDist - leftOffset) / slowTimes);///到达边界后速度放慢到原来5分之一 266 | left = Math.max(0, left); 267 | if (left < 0) { 268 | left = 0; 269 | } 270 | realRightOffset = left + width; 271 | } 272 | } else { 273 | realRightOffset = width; 274 | } 275 | } 276 | if (i != itemCount - 1) {//除最后一个外的右边缘慢速动画 277 | if (displayWidth - rightOffset <= width * edgePercent) { 278 | int edgeDist = (int) (displayWidth - width * edgePercent); 279 | int right = (int) (edgeDist + (rightOffset - edgeDist) / slowTimes); 280 | if (right >= displayWidth) { 281 | right = displayWidth; 282 | } 283 | realRightOffset = right; 284 | } 285 | } else { 286 | realRightOffset = totalWidth > displayWidth ? displayWidth : totalWidth; 287 | } 288 | layoutDecoratedWithMargins(view, realRightOffset - width, 0, realRightOffset, height); 289 | } 290 | } 291 | 292 | Log.d(TAG, "childCount = " + getChildCount() + " itemCount= " +itemCount); 293 | } 294 | 295 | private int getVerticalSpace() { 296 | // 计算RecyclerView的可用高度,除去上下Padding值 297 | return getHeight() - getPaddingBottom() - getPaddingTop(); 298 | } 299 | 300 | 301 | private int getHorizontalSpace() { 302 | return getWidth() - getPaddingLeft() - getPaddingRight(); 303 | } 304 | 305 | 306 | public void setEdgePercent(@FloatRange(from = 0.01, to = 1.0) float edgePercent) { 307 | this.edgePercent = edgePercent; 308 | } 309 | 310 | /** 311 | * {@inheritDoc} 312 | */ 313 | @Override 314 | public View findViewByPosition(int position) { 315 | final int childCount = getChildCount(); 316 | if (childCount == 0) { 317 | return null; 318 | } 319 | final int firstChild = getPosition(getChildAt(0)); 320 | final int viewPosition = position - firstChild; 321 | if (viewPosition >= 0 && viewPosition < childCount) { 322 | final View child = getChildAt(viewPosition); 323 | if (getPosition(child) == position) { 324 | return child; // in pre-layout, this may not match 325 | } 326 | } 327 | return super.findViewByPosition(position); 328 | } 329 | 330 | @Override 331 | public void scrollToPosition(int position) { 332 | 333 | offsetUseful = true; 334 | if (orientation == OrientationHelper.VERTICAL && viewHeight != 0) { 335 | verticalScrollOffset = position * viewHeight; 336 | } else if (orientation == OrientationHelper.HORIZONTAL && viewWidth != 0) { 337 | horizontalScrollOffset = position * viewWidth; 338 | } 339 | requestLayout(); 340 | } 341 | 342 | public void setSlowTimes(@IntRange(from = 1) int slowTimes) { 343 | this.slowTimes = slowTimes; 344 | } 345 | 346 | 347 | } 348 | 349 | -------------------------------------------------------------------------------- /app/src/main/res/anim/dialog_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/anim/dialog_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /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-xxhdpi/ie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/drawable-xxhdpi/ie.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ie_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/drawable-xxhdpi/ie_select.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/drawable-xxhdpi/qq.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/qq_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/drawable-xxhdpi/qq_select.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/sogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/drawable-xxhdpi/sogo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/sogo_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/drawable-xxhdpi/sogo_select.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_ie.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_qq.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_sogo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 16 | 21 | 26 | 31 | 36 | 41 | 46 | 51 | 56 | 61 | 66 | 71 | 76 | 81 | 86 | 91 | 96 | 101 | 106 | 111 | 116 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 172 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_horizontal.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 21 | 22 | 32 | 33 | 43 | 44 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_vertial.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_vertial2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 19 | 20 | 25 | 26 | 33 | 34 | 41 | 42 | 49 | 50 | 51 | 52 | 57 | 58 | 65 | 66 | 73 | 74 | 81 | 82 | 83 | 84 | 89 | 90 | 97 | 98 | 105 | 106 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_card.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_card_hor.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 18 | 19 | 20 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | OverlyingView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/test/java/com/renny/contractgridview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.renny.contractgridview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Dec 05 10:47:27 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /image/gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/image/gif.gif -------------------------------------------------------------------------------- /image/hor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/image/hor.gif -------------------------------------------------------------------------------- /image/ver.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ren93/OverFlyingView/fb50864247df2f7cc1cb353a16d0d703110b3df0/image/ver.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------