GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sysn · JingMeng/AndroidCustomView@5099d4f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • app/src/main/java/com/allen/androidcustomview/activity
    • AliPayHomeActivity.java
    • MainActivity.kt
    • RevealAnimationActivity.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎app/src/main/java/com/allen/androidcustomview/activity/AliPayHomeActivity.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/allen/androidcustomview/activity/AliPayHomeActivity.java
+39-10Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
* </pre>
1919
*/
2020
public class AliPayHomeActivity extends AppCompatActivity implements AppBarLayout.OnOffsetChangedListener {
21-
21+
2222

2323
private AppBarLayout mAppBarLayout;
2424
private View mToolbarOpenBgView;
2525
private View mToolbarCloseBgView;
2626
private View mToolbarOpenLayout;
2727
private View mToolbarCloseLayout;
2828
private View contentBgView;
29+
2930
@Override
3031
protected void onCreate(@Nullable Bundle savedInstanceState) {
3132
super.onCreate(savedInstanceState);
@@ -40,35 +41,63 @@ private void initView() {
4041
mToolbarOpenBgView = findViewById(R.id.toolbar_open_bg_view);
4142
mToolbarOpenLayout = findViewById(R.id.include_toolbar_open);
4243

43-
mToolbarCloseBgView = findViewById(R.id.bg_toolbar_close);
44-
mToolbarCloseLayout = findViewById(R.id.include_toolbar_close);
45-
contentBgView = findViewById(R.id.content_bg_view);
44+
mToolbarCloseBgView = findViewById(R.id.bg_toolbar_close);
45+
mToolbarCloseLayout = findViewById(R.id.include_toolbar_close);
46+
contentBgView = findViewById(R.id.content_bg_view);
4647

47-
mAppBarLayout = findViewById(R.id.app_bar_layout);
48+
mAppBarLayout = findViewById(R.id.app_bar_layout);
4849
}
4950

51+
52+
/**
53+
* 所有的知识点,都在这个动画部分了
54+
*
55+
* @param appBarLayout the {@link AppBarLayout} which offset has changed
56+
* @param verticalOffset the vertical offset for the parent {@link AppBarLayout}, in px
57+
* <p>
58+
* <p>
59+
* 三部分动画,顶部两部分是交叉变换动画
60+
* 下边是一个渐变的展示和隐藏操作
61+
*/
5062
@Override
5163
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
5264

5365
//垂直方向偏移量
5466
int offset = Math.abs(verticalOffset);
5567
//最大偏移距离
5668
int scrollRange = appBarLayout.getTotalScrollRange();
57-
if (offset <= scrollRange / 2) {//当滑动没超过一半,展开状态下toolbar显示内容,根据收缩位置,改变透明值
69+
if (offset <= scrollRange / 2) {
70+
/**
71+
* 当滑动没超过一半,展开状态下toolbar显示内容,根据收缩位置,改变透明值
72+
*/
73+
//搜索的那一部分
5874
mToolbarOpenLayout.setVisibility(View.VISIBLE);
75+
//功能图标部分
5976
mToolbarCloseLayout.setVisibility(View.GONE);
6077
//根据偏移百分比 计算透明值
61-
float scale2 = (float) offset / (scrollRange / 2);
78+
float scale2 = (float) offset / (scrollRange * 1.0f / 2);
6279
int alpha2 = (int) (255 * scale2);
80+
//背景 在上面 ,渐变效果的出现,并不是针对每一个view
6381
mToolbarOpenBgView.setBackgroundColor(Color.argb(alpha2, 25, 131, 209));
64-
} else {//当滑动超过一半,收缩状态下toolbar显示内容,根据收缩位置,改变透明值
82+
} else {
83+
/**
84+
* 当滑动超过一半,收缩状态下toolbar显示内容,根据收缩位置,改变透明值
85+
*/
6586
mToolbarOpenLayout.setVisibility(View.GONE);
6687
mToolbarCloseLayout.setVisibility(View.VISIBLE);
67-
float scale3 = (float) (scrollRange - offset) / (scrollRange / 2);
88+
89+
float scale3 = (float) (scrollRange - offset) / (scrollRange * 1.0f / 2);
6890
int alpha3 = (int) (255 * scale3);
6991
mToolbarCloseBgView.setBackgroundColor(Color.argb(alpha3, 25, 131, 209));
7092
}
71-
//根据偏移百分比计算扫一扫布局的透明度值
93+
/**
94+
*
95+
* 根据偏移百分比计算扫一扫布局的透明度值
96+
*
97+
* offset 越大, alpha 越接近 255
98+
*
99+
* 透明0-255,值越大越不透明
100+
*/
72101
float scale = (float) offset / scrollRange;
73102
int alpha = (int) (255 * scale);
74103
contentBgView.setBackgroundColor(Color.argb(alpha, 25, 131, 209));
Collapse file

‎app/src/main/java/com/allen/androidcustomview/activity/MainActivity.kt‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/allen/androidcustomview/activity/MainActivity.kt
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,19 @@ class MainActivity : AppCompatActivity(), BaseQuickAdapter.OnItemClickListener {
102102
10 -> startActivity(Intent(this@MainActivity, BannerActivity::class.java))
103103
/**
104104
* 吸顶动画
105+
*
106+
* 本质是一个rv的 itemdection的应用
105107
*/
106108
11 -> startActivity(Intent(this@MainActivity, HoverItemActivity::class.java))
109+
/**
110+
* 这个学习
111+
*/
107112
12 -> startActivity(Intent(this@MainActivity, RevealAnimationActivity::class.java))
113+
/**
114+
* 这个学习
115+
*
116+
* 再想想那种感觉
117+
*/
108118
13 -> startActivity(Intent(this@MainActivity, AliPayHomeActivity::class.java))
109119
14 -> startActivity(Intent(this@MainActivity, RecyclerViewItemAnimActivity::class.java))
110120
15 -> startActivity(Intent(this@MainActivity, PathActivity::class.java))
Collapse file

‎app/src/main/java/com/allen/androidcustomview/activity/RevealAnimationActivity.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/allen/androidcustomview/activity/RevealAnimationActivity.java
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ public void onClick(View v) {
4343
final float radius = (float) Math.hypot(imageView.getWidth(), imageView.getHeight());
4444

4545
if (imageView.getVisibility() == View.VISIBLE) {
46+
//5.0 之上就可以有api实现
4647
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
48+
/**
49+
* create Circular Reveal
50+
*
51+
* 创建循环显示
52+
*/
4753
Animator animator = ViewAnimationUtils.createCircularReveal(imageView, centerX, centerY, radius, 0);
4854
animator.setDuration(3000);
4955
animator.addListener(new Animator.AnimatorListener() {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.