Skip to content

Commit 593ccf2

Browse files
committed
侧滑清屏
1 parent 10df1bb commit 593ccf2

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<activity android:name=".activity.RecyclerViewItemAnimActivity" />
4040
<activity android:name=".activity.PathActivity" />
4141
<activity android:name=".activity.SinaVoteActivity" />
42+
<activity android:name=".activity.ClearScreenActivity" />
4243
</application>
4344

4445
</manifest>
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.allen.androidcustomview.activity
22

3+
import android.os.Bundle
4+
import android.support.v7.app.AppCompatActivity
5+
import com.allen.androidcustomview.R
6+
import kotlinx.android.synthetic.main.activity_clear_screen.*
7+
38
/**
49
* <pre>
510
* author : Allen
@@ -8,5 +13,11 @@ package com.allen.androidcustomview.activity
813
* desc :
914
* </pre>
1015
*/
11-
class ClearScreenActivity {
16+
class ClearScreenActivity : AppCompatActivity() {
17+
18+
override fun onCreate(savedInstanceState: Bundle?) {
19+
super.onCreate(savedInstanceState)
20+
setContentView(R.layout.activity_clear_screen)
21+
clear_screen_container.addClearView(iv_clear_content)
22+
}
1223
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class MainActivity : AppCompatActivity(), BaseQuickAdapter.OnItemClickListener {
4242
typeBeans.add(TypeBean("RecyclerView的item动画", 14))
4343
typeBeans.add(TypeBean("路径path动画", 15))
4444
typeBeans.add(TypeBean("仿新浪投票控件", 16))
45+
typeBeans.add(TypeBean("直播侧滑清屏效果", 17))
4546
return typeBeans
4647
}
4748

@@ -84,6 +85,7 @@ class MainActivity : AppCompatActivity(), BaseQuickAdapter.OnItemClickListener {
8485
14 -> startActivity(Intent(this@MainActivity, RecyclerViewItemAnimActivity::class.java))
8586
15 -> startActivity(Intent(this@MainActivity, PathActivity::class.java))
8687
16 -> startActivity(Intent(this@MainActivity, SinaVoteActivity::class.java))
88+
17 -> startActivity(Intent(this@MainActivity, ClearScreenActivity::class.java))
8789
}
8890
}
8991
}

app/src/main/java/com/allen/androidcustomview/widget/ClearScreenView.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.spero.vision.vsnapp.support.widget.live
1+
package com.allen.androidcustomview.widget
22

33
import android.animation.Animator
44
import android.animation.AnimatorListenerAdapter
@@ -10,15 +10,14 @@ import android.view.VelocityTracker
1010
import android.view.View
1111
import android.view.ViewGroup
1212
import android.widget.FrameLayout
13-
import com.ytx.logutil.YtxLog
1413
import kotlin.math.abs
1514

1615

1716
/**
1817
* <pre>
1918
* @author : Allen
20-
* e-mail : yagang.li@yintech.cn
21-
* date : 2020/03/27
19+
* e-mail : lygttpod@163.com
20+
* date : 2021/01/28
2221
* desc : 滑动清屏view
2322
* </pre>
2423
*/
@@ -177,7 +176,6 @@ class ClearScreenView @JvmOverloads constructor(val mContext: Context, attrs: At
177176
MotionEvent.ACTION_UP -> {
178177
mVelocityTracker?.computeCurrentVelocity(10)
179178
val xVelocity = mVelocityTracker?.xVelocity ?: 0f
180-
YtxLog.d("ClearScreenViw", "onTouchEvent------xVelocity=$xVelocity")
181179
when {
182180
//从左往右滑动(是正数)速度大于阈值
183181
xVelocity > MIN_X_VELOCITY -> {
@@ -261,6 +259,12 @@ class ClearScreenView @JvmOverloads constructor(val mContext: Context, attrs: At
261259
}
262260
}
263261

262+
fun addClearView(view: View) {
263+
if (!listClearViews.contains(view)) {
264+
listClearViews.add(view)
265+
}
266+
}
267+
264268
fun removeClearViews(views: List<View>) {
265269
for (view in views) {
266270
listClearViews.remove(view)
Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:orientation="vertical" android:layout_width="match_parent"
2+
<com.allen.androidcustomview.widget.ClearScreenView xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:id="@+id/clear_screen_container"
5+
android:layout_width="match_parent"
46
android:layout_height="match_parent">
57

6-
</LinearLayout>
8+
<FrameLayout
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent">
11+
12+
<TextView
13+
android:layout_width="match_parent"
14+
android:layout_height="match_parent"
15+
android:gravity="center"
16+
android:text="我是屏幕固定内容区域" />
17+
18+
<ImageView
19+
android:id="@+id/iv_clear_content"
20+
android:layout_width="match_parent"
21+
android:layout_height="match_parent"
22+
android:gravity="center"
23+
android:scaleType="fitXY"
24+
android:src="@mipmap/live_bg" />
25+
</FrameLayout>
26+
</com.allen.androidcustomview.widget.ClearScreenView>

0 commit comments

Comments
 (0)