Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
门心叼龙
android-touch-event
提交
bbb7351f
A
android-touch-event
项目概览
门心叼龙
/
android-touch-event
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
android-touch-event
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
bbb7351f
编写于
5月 13, 2019
作者:
门心叼龙
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
map touch add
上级
50fada76
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
903 addition
and
3 deletion
+903
-3
.idea/vcs.xml
.idea/vcs.xml
+6
-0
app/build.gradle
app/build.gradle
+2
-0
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+19
-0
app/src/main/java/com/android/touchevent/MainActivity.java
app/src/main/java/com/android/touchevent/MainActivity.java
+9
-0
app/src/main/java/com/android/touchevent/MapTouchActivity.java
...rc/main/java/com/android/touchevent/MapTouchActivity.java
+41
-0
app/src/main/java/com/android/touchevent/MyApplication.java
app/src/main/java/com/android/touchevent/MyApplication.java
+22
-0
app/src/main/java/com/android/touchevent/util/BlogViewController.java
.../java/com/android/touchevent/util/BlogViewController.java
+120
-0
app/src/main/java/com/android/touchevent/util/DisplayUtil.java
...rc/main/java/com/android/touchevent/util/DisplayUtil.java
+100
-0
app/src/main/java/com/android/touchevent/view/BlogMapView.java
...rc/main/java/com/android/touchevent/view/BlogMapView.java
+76
-0
app/src/main/java/com/android/touchevent/view/BlogTransView.java
.../main/java/com/android/touchevent/view/BlogTransView.java
+78
-0
app/src/main/java/com/android/touchevent/view/MyLayout.java
app/src/main/java/com/android/touchevent/view/MyLayout.java
+3
-3
app/src/main/java/com/android/touchevent/view/TransScrollView.java
...ain/java/com/android/touchevent/view/TransScrollView.java
+35
-0
app/src/main/res/drawable/ic_zoom_btn.xml
app/src/main/res/drawable/ic_zoom_btn.xml
+6
-0
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+1
-0
app/src/main/res/layout/activity_trip_detail.xml
app/src/main/res/layout/activity_trip_detail.xml
+239
-0
app/src/main/res/layout/view_blog_map.xml
app/src/main/res/layout/view_blog_map.xml
+21
-0
app/src/main/res/layout/view_blog_over.xml
app/src/main/res/layout/view_blog_over.xml
+97
-0
app/src/main/res/layout/view_blog_trans.xml
app/src/main/res/layout/view_blog_trans.xml
+15
-0
app/src/main/res/mipmap-xhdpi/s_map_icon_enlarge.png
app/src/main/res/mipmap-xhdpi/s_map_icon_enlarge.png
+0
-0
app/src/main/res/mipmap-xhdpi/s_map_icon_reduce.png
app/src/main/res/mipmap-xhdpi/s_map_icon_reduce.png
+0
-0
app/src/main/res/values/dimens.xml
app/src/main/res/values/dimens.xml
+3
-0
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+1
-0
app/src/main/res/values/styles.xml
app/src/main/res/values/styles.xml
+9
-0
未找到文件。
.idea/vcs.xml
0 → 100644
浏览文件 @
bbb7351f
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
app/build.gradle
浏览文件 @
bbb7351f
...
...
@@ -22,6 +22,8 @@ dependencies {
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
'com.android.support:appcompat-v7:28.0.0'
implementation
'com.android.support.constraint:constraint-layout:1.1.3'
implementation
'com.amap.api:navi-3dmap:latest.integration'
implementation
'com.android.support:design:28.0.0'
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'
...
...
app/src/main/AndroidManifest.xml
浏览文件 @
bbb7351f
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.android.touchevent"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<application
android:allowBackup=
"true"
...
...
@@ -8,6 +18,7 @@
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:name=
".MyApplication"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".MainActivity"
>
<intent-filter>
...
...
@@ -16,6 +27,14 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".MapTouchActivity"
android:label=
"@string/title_activity_trip_detail"
android:theme=
"@style/AppTheme.NoActionBar"
>
</activity>
<meta-data
android:name=
"com.amap.api.v2.apikey"
android:value=
"8eecfc5d75d050cdd6d872e09073ca1e"
/>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/android/touchevent/MainActivity.java
浏览文件 @
bbb7351f
package
com.android.touchevent
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
com.android.touchevent.util.MotionEventUtil
;
...
...
@@ -20,6 +22,13 @@ public class MainActivity extends AppCompatActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
findViewById
(
R
.
id
.
btn_test
).
setOnClickListener
(
new
View
.
OnClickListener
(){
@Override
public
void
onClick
(
View
v
)
{
startActivity
(
new
Intent
(
MainActivity
.
this
,
MapTouchActivity
.
class
));
}
});
}
@Override
...
...
app/src/main/java/com/android/touchevent/MapTouchActivity.java
0 → 100644
浏览文件 @
bbb7351f
package
com.android.touchevent
;
import
android.os.Bundle
;
import
android.support.design.widget.FloatingActionButton
;
import
android.support.design.widget.Snackbar
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.view.View
;
import
android.widget.RelativeLayout
;
import
com.android.touchevent.util.BlogViewController
;
import
com.android.touchevent.view.BlogMapView
;
import
com.android.touchevent.view.BlogTransView
;
import
com.android.touchevent.view.TransScrollView
;
public
class
MapTouchActivity
extends
AppCompatActivity
{
private
RelativeLayout
mLayoutBlogRoot
;
private
BlogMapView
mBlogMapView
;
private
BlogTransView
mBlogTransView
;
private
TransScrollView
mTransScrollView
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_trip_detail
);
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
mBlogMapView
=
findViewById
(
R
.
id
.
blog_map_view
);
mBlogTransView
=
findViewById
(
R
.
id
.
view_blog_trans
);
mTransScrollView
=
findViewById
(
R
.
id
.
view_scrollview
);
mLayoutBlogRoot
=
findViewById
(
R
.
id
.
layout_blog_root
);
mBlogMapView
.
onCreate
(
savedInstanceState
);
BlogViewController
mBlogViewController
=
new
BlogViewController
(
mLayoutBlogRoot
,
mBlogMapView
,
mTransScrollView
,
mBlogTransView
);
mBlogViewController
.
init
();
}
}
app/src/main/java/com/android/touchevent/MyApplication.java
0 → 100644
浏览文件 @
bbb7351f
package
com.android.touchevent
;
import
android.app.Application
;
/**
* Description: <MyApplication><br>
* Author: gxl<br>
* Date: 2019/5/13<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public
class
MyApplication
extends
Application
{
public
static
MyApplication
mApplication
;
@Override
public
void
onCreate
()
{
super
.
onCreate
();
mApplication
=
this
;
}
public
static
MyApplication
getInstance
(){
return
mApplication
;
}
}
app/src/main/java/com/android/touchevent/util/BlogViewController.java
0 → 100644
浏览文件 @
bbb7351f
package
com.android.touchevent.util
;
import
android.animation.AnimatorSet
;
import
android.animation.ObjectAnimator
;
import
android.animation.ValueAnimator
;
import
android.graphics.Rect
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.widget.CompoundButton
;
import
android.widget.RelativeLayout
;
import
com.android.touchevent.view.BlogMapView
;
import
com.android.touchevent.view.BlogTransView
;
import
com.android.touchevent.view.TransScrollView
;
/**
* Description: <View协调控制器><br>
* Author: gxl<br>
* Date: 2019/1/25<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public
class
BlogViewController
{
public
static
final
String
TAG
=
BlogViewController
.
class
.
getSimpleName
();
private
RelativeLayout
mLayoutBlogRoot
;
private
BlogMapView
mBlogMapView
;
private
TransScrollView
mTransScrollView
;
private
BlogTransView
mBlogTransView
;
public
BlogViewController
(
RelativeLayout
layoutBlogRoot
,
BlogMapView
blogMapView
,
TransScrollView
transScrollView
,
BlogTransView
blogTransView
)
{
mLayoutBlogRoot
=
layoutBlogRoot
;
mBlogMapView
=
blogMapView
;
mTransScrollView
=
transScrollView
;
mBlogTransView
=
blogTransView
;
}
public
void
init
()
{
mBlogTransView
.
setListener
(
new
BlogTransView
.
TouchEventListener
()
{
@Override
public
boolean
dispatchTouchEvent
(
MotionEvent
event
)
{
return
mBlogMapView
.
dispatchMapTouchEvent
(
event
);
}
});
mBlogTransView
.
setBtnMapZoomOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
//如果不是人手动点击则返回
if
(!
compoundButton
.
isPressed
())
{
return
;
}
mBlogMapView
.
setBtnMapZoomChecked
(
b
);
setFlexWindow
(
b
);
}
});
mTransScrollView
.
setListener
(
new
BlogTransView
.
TouchEventListener
()
{
@Override
public
boolean
dispatchTouchEvent
(
MotionEvent
event
)
{
Rect
rect
=
new
Rect
();
mBlogTransView
.
getLocalVisibleRect
(
rect
);
if
(
rect
.
contains
((
int
)
event
.
getX
(),
(
int
)
event
.
getY
()))
{
return
true
;
}
else
{
return
false
;
}
}
});
}
//设置弹性窗口true:展开;false:收缩
private
void
setFlexWindow
(
boolean
b
)
{
//当为true的时候:1.ScrollView要往下移动,是一个位移动画;
//当为false的时候:1.ScrollView要往上移动,是一个位移动画;
//往下移动,要移动多少?其实就是整个内容区域的高度,也就是layoutRoot的高度,恢复高度为0即可
//MapView要缩放,要放大到多少倍?其他就是layoutRoot的高度除以MapView的高度
//计算MapView的高度
Rect
rect
=
new
Rect
();
mBlogTransView
.
getLocalVisibleRect
(
rect
);
int
mMapViewHeight
=
DisplayUtil
.
dip2px
(
250
);
//不判断将是个大Bug
if
(
rect
.
height
()
<
mMapViewHeight
-
DisplayUtil
.
dip2px
(
30
))
{
mBlogTransView
.
setBtnMapZoomChecked
(!
b
);
mBlogMapView
.
setBtnMapZoomChecked
(!
b
);
return
;
}
Log
.
v
(
TAG
,
"mapview height:"
+
mMapViewHeight
);
//计算整个内容区域的高度
int
mRootHeight
=
mLayoutBlogRoot
.
getHeight
();
Log
.
v
(
TAG
,
"rootlayout height:"
+
mRootHeight
);
int
offset
=
mRootHeight
-
mMapViewHeight
;
Log
.
v
(
TAG
,
"offset height:"
+
offset
);
Log
.
v
(
TAG
,
"scrollview width:"
+
mTransScrollView
.
getWidth
()
+
";height:"
+
mTransScrollView
.
getHeight
()
+
";x:"
+
mTransScrollView
.
getX
()
+
";y:"
+
mTransScrollView
.
getY
());
if
(
b
)
{
expendAnimator
(
mMapViewHeight
,
mRootHeight
,
offset
);
}
else
{
expendAnimator
(
mRootHeight
,
mMapViewHeight
,
0
);
}
}
private
void
expendAnimator
(
int
mMapViewHeight
,
int
mRootHeight
,
int
offset
)
{
//创建ScrollView向下移动移动
ObjectAnimator
translateAnimator
=
ObjectAnimator
.
ofFloat
(
mTransScrollView
,
"translationY"
,
offset
);
//创建地图放大动画
ValueAnimator
valueAnimator
=
ValueAnimator
.
ofInt
(
mMapViewHeight
,
mRootHeight
);
valueAnimator
.
addUpdateListener
(
new
ValueAnimator
.
AnimatorUpdateListener
()
{
@Override
public
void
onAnimationUpdate
(
ValueAnimator
valueAnimator
)
{
int
animatedValue
=
(
int
)
valueAnimator
.
getAnimatedValue
();
Log
.
v
(
TAG
,
"map height:"
+
animatedValue
);
mBlogMapView
.
setMapLayoutParams
(
animatedValue
);
}
});
//合成两个动画效果
AnimatorSet
animatorSet
=
new
AnimatorSet
();
animatorSet
.
play
(
translateAnimator
).
with
(
valueAnimator
);
animatorSet
.
setDuration
(
1000
);
animatorSet
.
start
();
}
}
app/src/main/java/com/android/touchevent/util/DisplayUtil.java
0 → 100644
浏览文件 @
bbb7351f
package
com.android.touchevent.util
;
import
android.content.Context
;
import
com.android.touchevent.MyApplication
;
/**
* Android大小单位转换工具类
*
* DisplayMetrics dm = context.getResources().getDisplayMetrics(); DensityUtil?
*/
public
class
DisplayUtil
{
private
static
Context
context
=
MyApplication
.
getInstance
().
getApplicationContext
();
/**
* 将px值转换为dip或dp值,保证尺寸大小不变
*
* @param pxValue
* @param scale (DisplayMetrics类中属性density)
* @return
*/
public
static
int
px2dip
(
float
pxValue
,
float
scale
)
{
return
(
int
)
(
pxValue
/
scale
+
0.5f
);
}
/**
* 将px值转换为dip或dp值,保证尺寸大小不变
*
* @param pxValue (DisplayMetrics类中属性density)
* @return
*/
public
static
int
px2dip
(
float
pxValue
)
{
return
(
int
)
(
pxValue
/
context
.
getResources
().
getDisplayMetrics
().
density
+
0.5f
);
}
/**
* 将dip或dp值转换为px值,保证尺寸大小不变
*
* @param dipValue
* @param scale (DisplayMetrics类中属性density)
* @return
*/
public
static
int
dip2px
(
float
dipValue
,
float
scale
)
{
return
(
int
)
(
dipValue
*
scale
+
0.5f
);
}
/**
* 将dip或dp值转换为px值,保证尺寸大小不变
*
* @param dipValue
* @return
*/
public
static
int
dip2px
(
float
dipValue
)
{
return
(
int
)
(
dipValue
*
context
.
getResources
().
getDisplayMetrics
().
density
+
0.5f
);
}
/**
* 将px值转换为sp值,保证文字大小不变
*
* @param pxValue
* @param fontScale (DisplayMetrics类中属性scaledDensity)
* @return
*/
public
static
int
px2sp
(
float
pxValue
,
float
fontScale
)
{
return
(
int
)
(
pxValue
/
fontScale
+
0.5f
);
}
/**
* 将px值转换为sp值,保证文字大小不变
*
* @param pxValue
* @return
*/
public
static
int
px2sp
(
float
pxValue
)
{
return
(
int
)
(
pxValue
/
context
.
getResources
().
getDisplayMetrics
().
scaledDensity
+
0.5f
);
}
/**
* 将sp值转换为px值,保证文字大小不变
*
* @param spValue
* @param fontScale (DisplayMetrics类中属性scaledDensity)
* @return
*/
public
static
int
sp2px
(
float
spValue
,
float
fontScale
)
{
return
(
int
)
(
spValue
*
fontScale
+
0.5f
);
}
/**
* 将sp值转换为px值,保证文字大小不变
*
* @param spValue
* @return
*/
public
static
int
sp2px
(
float
spValue
)
{
return
(
int
)
(
spValue
*
context
.
getResources
().
getDisplayMetrics
().
scaledDensity
+
0.5f
);
}
}
app/src/main/java/com/android/touchevent/view/BlogMapView.java
0 → 100644
浏览文件 @
bbb7351f
package
com.android.touchevent.view
;
import
android.content.Context
;
import
android.os.Bundle
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
import
android.widget.CheckBox
;
import
android.widget.RelativeLayout
;
import
com.amap.api.maps.AMap
;
import
com.amap.api.maps.TextureMapView
;
import
com.android.touchevent.R
;
/**
* Description: <BlogMapView><br>
* Author: gxl<br>
* Date: 2019/1/25<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public
class
BlogMapView
extends
RelativeLayout
{
public
static
final
String
TAG
=
BlogMapView
.
class
.
getSimpleName
();
private
AMap
mMap
;
private
TextureMapView
mTextureMapView
;
private
CheckBox
mBtnMapZoom
;
public
BlogMapView
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
view_blog_map
,
this
,
true
);
mTextureMapView
=
findViewById
(
R
.
id
.
map
);
mMap
=
mTextureMapView
.
getMap
();
mMap
.
getUiSettings
().
setZoomControlsEnabled
(
false
);
mBtnMapZoom
=
findViewById
(
R
.
id
.
btn_map_zoom
);
}
public
boolean
dispatchMapTouchEvent
(
MotionEvent
event
)
{
return
mTextureMapView
.
dispatchTouchEvent
(
event
);
}
public
void
setMapLayoutParams
(
int
height
)
{
setLayoutParams
(
new
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
height
));
mTextureMapView
.
setLayoutParams
(
new
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
height
));
}
public
void
setBtnMapZoomChecked
(
boolean
b
)
{
if
(
mBtnMapZoom
!=
null
)
{
mBtnMapZoom
.
setChecked
(
b
);
}
}
public
void
onCreate
(
Bundle
bundle
)
{
mTextureMapView
.
onCreate
(
bundle
);
}
public
void
onResume
()
{
mTextureMapView
.
onResume
();
}
public
void
onSaveInstanceState
(
Bundle
outState
)
{
mTextureMapView
.
onSaveInstanceState
(
outState
);
}
public
void
onPause
()
{
mTextureMapView
.
onPause
();
}
public
void
onDestroy
()
{
mTextureMapView
.
onDestroy
();
}
public
AMap
getMap
()
{
return
mMap
;
}
}
app/src/main/java/com/android/touchevent/view/BlogTransView.java
0 → 100644
浏览文件 @
bbb7351f
package
com.android.touchevent.view
;
import
android.content.Context
;
import
android.graphics.Rect
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
import
android.widget.CheckBox
;
import
android.widget.CompoundButton
;
import
android.widget.RelativeLayout
;
import
com.android.touchevent.R
;
/**
* Description: <BlogTransView><br>
* Author: gxl<br>
* Date: 2019/1/25<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public
class
BlogTransView
extends
RelativeLayout
{
public
static
final
String
TAG
=
BlogTransView
.
class
.
getSimpleName
();
private
BlogTransView
.
TouchEventListener
mListener
;
private
CheckBox
mBtnMapZoom
;
private
CompoundButton
.
OnCheckedChangeListener
mChangeListener
;
public
interface
TouchEventListener
{
boolean
dispatchTouchEvent
(
MotionEvent
event
);
}
public
BlogTransView
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
view_blog_trans
,
this
,
true
);
mBtnMapZoom
=
findViewById
(
R
.
id
.
btn_map_zoom
);
mBtnMapZoom
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
if
(
mChangeListener
!=
null
)
{
mChangeListener
.
onCheckedChanged
(
compoundButton
,
b
);
}
}
});
}
@Override
public
boolean
dispatchTouchEvent
(
MotionEvent
event
)
{
if
(
mListener
!=
null
)
{
Rect
rect
=
new
Rect
();
mBtnMapZoom
.
getHitRect
(
rect
);
Log
.
v
(
TAG
,
"x:"
+
event
.
getX
()
+
";y:"
+
event
.
getY
());
if
(
rect
.
contains
((
int
)
event
.
getX
(),
(
int
)
event
.
getY
()))
{
Log
.
v
(
TAG
,
"mBtnMapZoom click yes"
);
return
super
.
dispatchTouchEvent
(
event
);
//继续往下分发给CheckBox
}
else
{
Log
.
v
(
TAG
,
"mBtnMapZoom click no"
);
return
mListener
.
dispatchTouchEvent
(
event
);
}
}
else
{
return
super
.
dispatchTouchEvent
(
event
);
}
}
public
void
setListener
(
BlogTransView
.
TouchEventListener
listener
)
{
mListener
=
listener
;
}
public
void
setBtnMapZoomOnCheckedChangeListener
(
CompoundButton
.
OnCheckedChangeListener
listener
)
{
mChangeListener
=
listener
;
}
public
void
setBtnMapZoomChecked
(
boolean
b
)
{
if
(
mBtnMapZoom
!=
null
)
{
mBtnMapZoom
.
setChecked
(
b
);
}
}
}
app/src/main/java/com/android/touchevent/view/MyLayout.java
浏览文件 @
bbb7351f
...
...
@@ -25,18 +25,18 @@ public class MyLayout extends LinearLayout {
@Override
public
boolean
dispatchTouchEvent
(
MotionEvent
ev
)
{
Log
.
v
(
TAG
,
"MyLayout dispatchTouchEvent start:"
+
MotionEventUtil
.
getMotionEventName
(
ev
));
return
true
;
return
super
.
dispatchTouchEvent
(
ev
)
;
}
@Override
public
boolean
onInterceptTouchEvent
(
MotionEvent
ev
)
{
Log
.
v
(
TAG
,
"MyLayout onInterceptTouchEvent start:"
+
MotionEventUtil
.
getMotionEventName
(
ev
));
return
true
;
return
super
.
onInterceptTouchEvent
(
ev
)
;
}
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
Log
.
v
(
TAG
,
"MyLayout onTouchEvent start:"
+
MotionEventUtil
.
getMotionEventName
(
event
));
return
true
;
return
super
.
onTouchEvent
(
event
)
;
}
}
app/src/main/java/com/android/touchevent/view/TransScrollView.java
0 → 100644
浏览文件 @
bbb7351f
package
com.android.touchevent.view
;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.v4.widget.NestedScrollView
;
import
android.util.AttributeSet
;
import
android.view.MotionEvent
;
/**
* Description: <TransScrollView><br>
* Author: gxl<br>
* Date: 2018/12/29<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public
class
TransScrollView
extends
NestedScrollView
{
public
BlogTransView
.
TouchEventListener
mListener
;
public
TransScrollView
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
@Override
public
boolean
onInterceptTouchEvent
(
MotionEvent
ev
)
{
if
(
mListener
!=
null
&&
mListener
.
dispatchTouchEvent
(
ev
))
{
return
false
;
}
return
super
.
onInterceptTouchEvent
(
ev
);
}
public
void
setListener
(
BlogTransView
.
TouchEventListener
listener
)
{
mListener
=
listener
;
}
}
app/src/main/res/drawable/ic_zoom_btn.xml
0 → 100644
浏览文件 @
bbb7351f
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:state_checked=
"false"
android:drawable=
"@mipmap/s_map_icon_enlarge"
/>
<item
android:state_checked=
"true"
android:drawable=
"@mipmap/s_map_icon_reduce"
/>
<item
android:drawable=
"@mipmap/s_map_icon_enlarge"
/>
</selector>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
浏览文件 @
bbb7351f
...
...
@@ -8,6 +8,7 @@
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<com.android.touchevent.view.MyButton
android:id=
"@+id/btn_test"
android:layout_width=
"200dp"
android:layout_height=
"100dp"
android:text=
"点击测试"
...
...
app/src/main/res/layout/activity_trip_detail.xml
0 → 100644
浏览文件 @
bbb7351f
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:orientation=
"vertical"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<android.support.v7.widget.Toolbar
android:id=
"@+id/toolbar"
android:layout_width=
"match_parent"
android:layout_height=
"?attr/actionBarSize"
android:background=
"?attr/colorPrimary"
app:popupTheme=
"@style/AppTheme.PopupOverlay"
/>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/layout_blog_root"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<com.android.touchevent.view.BlogMapView
android:id=
"@+id/blog_map_view"
android:layout_width=
"match_parent"
android:layout_height=
"250dp"
android:layout_alignParentTop=
"true"
/>
<com.android.touchevent.view.TransScrollView
android:id=
"@+id/view_scrollview"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_alignParentTop=
"true"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<com.android.touchevent.view.BlogTransView
android:id=
"@+id/view_blog_trans"
android:layout_width=
"match_parent"
android:layout_height=
"250dp"
android:background=
"#00000000"
/>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/layout_blog_detail"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"#ffffff"
android:orientation=
"vertical"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
android:background=
"#ffffff"
android:paddingLeft=
"16dp"
android:paddingRight=
"16dp"
>
<TextView
android:id=
"@+id/txt_trip_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:text=
"RxJava详解"
android:textColor=
"#333333"
android:textSize=
"15sp"
/>
<View
android:layout_width=
"30dp"
android:layout_height=
"3dp"
android:layout_alignLeft=
"@+id/txt_trip_title"
android:layout_alignParentBottom=
"true"
android:background=
"#FB8C00"
/>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_alignParentBottom=
"true"
android:background=
"#EDEDED"
/>
</RelativeLayout>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
</LinearLayout>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"#ffffff"
android:orientation=
"vertical"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
>
<TextView
android:id=
"@+id/txt_media_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"16dp"
android:text=
"Dagger详解"
android:textColor=
"#333333"
android:textSize=
"15sp"
/>
<View
android:layout_width=
"30dp"
android:layout_height=
"3dp"
android:layout_above=
"@+id/view_bottom_line"
android:layout_alignLeft=
"@+id/txt_media_title"
android:background=
"#FB8C00"
/>
<View
android:id=
"@+id/view_bottom_line"
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_alignLeft=
"@+id/txt_media_title"
android:layout_alignParentBottom=
"true"
android:background=
"#EDEDED"
/>
</RelativeLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:text=
"RxJava线程切换之subscribeOn和observeOn详解"
/>
</LinearLayout>
<View
android:layout_width=
"match_parent"
android:layout_height=
"10dp"
android:background=
"#EDEDED"
/>
</LinearLayout>
</LinearLayout>
</com.android.touchevent.view.TransScrollView>
</RelativeLayout>
</LinearLayout>
app/src/main/res/layout/view_blog_map.xml
0 → 100644
浏览文件 @
bbb7351f
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/layout_map_root"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<com.amap.api.maps.TextureMapView
android:id=
"@+id/map"
android:layout_width=
"match_parent"
android:layout_height=
"250dp"
/>
<CheckBox
android:id=
"@+id/btn_map_zoom"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignRight=
"@+id/map"
android:layout_alignBottom=
"@+id/map"
android:background=
"@drawable/ic_zoom_btn"
android:button=
"@null"
/>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/view_blog_over.xml
0 → 100644
浏览文件 @
bbb7351f
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/layout_blog_detail"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"#ffffff"
android:orientation=
"vertical"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
android:background=
"#ffffff"
android:paddingLeft=
"16dp"
android:paddingRight=
"16dp"
>
<TextView
android:id=
"@+id/txt_trip_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:text=
"行程详情"
android:textColor=
"#333333"
android:textSize=
"15sp"
/>
<View
android:layout_width=
"30dp"
android:layout_height=
"3dp"
android:layout_alignLeft=
"@+id/txt_trip_title"
android:layout_alignParentBottom=
"true"
android:background=
"#FB8C00"
/>
<TextView
android:id=
"@+id/txt_trip_edit"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
android:text=
"编辑"
android:textColor=
"#1E88E5"
android:textSize=
"15sp"
/>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_alignParentBottom=
"true"
android:background=
"#EDEDED"
/>
</RelativeLayout>
<TextView
android:id=
"@+id/txt_trip_describe"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"17dp"
android:layout_marginTop=
"15dp"
android:layout_marginRight=
"20dp"
android:layout_marginBottom=
"15dp"
android:textColor=
"#333333"
android:textSize=
"20sp"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/txt_trip_starttime"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"17dp"
android:textColor=
"#999999"
android:textSize=
"13sp"
/>
<TextView
android:id=
"@+id/txt_trip_cover_describe"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:layout_marginTop=
"10dp"
android:layout_marginRight=
"27dp"
android:textColor=
"#333333"
android:textSize=
"15sp"
/>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_marginTop=
"23dp"
android:background=
"#EDEDED"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/view_blog_trans.xml
0 → 100644
浏览文件 @
bbb7351f
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"250dp"
android:background=
"#00000000"
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<CheckBox
android:id=
"@+id/btn_map_zoom"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:button=
"@null"
/>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/mipmap-xhdpi/s_map_icon_enlarge.png
0 → 100644
浏览文件 @
bbb7351f
857 字节
app/src/main/res/mipmap-xhdpi/s_map_icon_reduce.png
0 → 100644
浏览文件 @
bbb7351f
858 字节
app/src/main/res/values/dimens.xml
0 → 100644
浏览文件 @
bbb7351f
<resources>
<dimen
name=
"fab_margin"
>
16dp
</dimen>
</resources>
app/src/main/res/values/strings.xml
浏览文件 @
bbb7351f
<resources>
<string
name=
"app_name"
>
AndroidTouchEvent
</string>
<string
name=
"title_activity_trip_detail"
>
MapTouchActivity
</string>
</resources>
app/src/main/res/values/styles.xml
浏览文件 @
bbb7351f
...
...
@@ -8,4 +8,13 @@
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
</style>
<style
name=
"AppTheme.NoActionBar"
>
<item
name=
"windowActionBar"
>
false
</item>
<item
name=
"windowNoTitle"
>
true
</item>
</style>
<style
name=
"AppTheme.AppBarOverlay"
parent=
"ThemeOverlay.AppCompat.Dark.ActionBar"
/>
<style
name=
"AppTheme.PopupOverlay"
parent=
"ThemeOverlay.AppCompat.Light"
/>
</resources>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录