Android (我应该如何)将map 2.0嵌入用户可以展开的功能区中?
我想在数据UI片段上方显示一个google map API 2.0,作为一个功能区,让用户能够展开地图,与之交互。插图:及 这样,当地图处于ribbon模式时,用户可以使用地图来说明自己的位置,而当用户ewpands地图(覆盖屏幕的4/5)时,他可以使用地图功能 我该怎么做?你是怎么想的 我在想Android (我应该如何)将map 2.0嵌入用户可以展开的功能区中?,android,design-patterns,ribbon,Android,Design Patterns,Ribbon,我想在数据UI片段上方显示一个google map API 2.0,作为一个功能区,让用户能够展开地图,与之交互。插图:及 这样,当地图处于ribbon模式时,用户可以使用地图来说明自己的位置,而当用户ewpands地图(覆盖屏幕的4/5)时,他可以使用地图功能 我该怎么做?你是怎么想的 我在想 从顶部滑动的抽屉,里面有地图 覆盖的“卡片界面”界面,用于在地图上显示数据 试图搞乱高度和焦点(但屏幕截图和用户交互的改进呼声就是这样做的) 有什么建议吗 谢谢你的创意和关注 免责声明:我知道这与i
- 从顶部滑动的抽屉,里面有地图
- 覆盖的“卡片界面”界面,用于在地图上显示数据
- 试图搞乱高度和焦点(但屏幕截图和用户交互的改进呼声就是这样做的)
免责声明:我知道这与iOS类似,但我正在将其转换为本机设计,现在应用程序使用ActionBarCompat,但我需要向您显示想要的结果(而不是当前状态)。如果有人需要,我会这样做:
- 我定义了一个LinearLayout来拦截用户操作并控制地图的扩展/缩小
- 我在相对布局中放了一个mapFragment v2.0李>
- 我在缩放地图时定义了滚动视图尺寸
<?xml version="1.0" encoding="utf-8"?>
<com.snapcar.rider.utils.LinearTouchEventLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pj="http://schemas.android.com/apk/res/com.snapcar.rider"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_red"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/map_fragment_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</RelativeLayout>
<ScrollView
android:id="@+id/scrollView1"
style="@style/sc_scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5" >
Layout content
</ScrollView>
</com.snapcar.rider.utils.LinearTouchEventLayout>
收缩/展开方法:
private void shrinkMap() {
Dbg.d(TAG, "shrinkMap");
DropDownAnim anim = new DropDownAnim(mScroll, false);
anim.setDuration(300);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Dbg.d(TAG, "DropDownAnim - shrink start");
isShrinking = true;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Dbg.d(TAG, "DropDownAnim shrink end");
isShrinking = false;
isMapShrinked = true;
adjustMapPosAndZoom();
}
});
getView().startAnimation(anim);
}
当然还有动画定义:
private class DropDownAnim extends Animation {
boolean down;
float maxRatio = 5;
float minRatio = 0.2f;
public DropDownAnim(View view, boolean down) {
this.down = down;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float currentRatio;
if (down) {
currentRatio = maxRatio - (float) ((maxRatio - minRatio) * interpolatedTime);
} else {
currentRatio = minRatio + (float) ((maxRatio - minRatio) * interpolatedTime);
}
LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
0, (float) currentRatio);
Dbg.d(TAG, "--- "+ currentRatio);
mScroll.setLayoutParams(param2);
root.requestLayout();
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
@Override
public boolean willChangeBounds() {
return true;
}
}
若你们有任何问题,那个些在那个篇帖子上挖洞的陌生人,请随时提问
private void shrinkMap() {
Dbg.d(TAG, "shrinkMap");
DropDownAnim anim = new DropDownAnim(mScroll, false);
anim.setDuration(300);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Dbg.d(TAG, "DropDownAnim - shrink start");
isShrinking = true;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Dbg.d(TAG, "DropDownAnim shrink end");
isShrinking = false;
isMapShrinked = true;
adjustMapPosAndZoom();
}
});
getView().startAnimation(anim);
}
private class DropDownAnim extends Animation {
boolean down;
float maxRatio = 5;
float minRatio = 0.2f;
public DropDownAnim(View view, boolean down) {
this.down = down;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
float currentRatio;
if (down) {
currentRatio = maxRatio - (float) ((maxRatio - minRatio) * interpolatedTime);
} else {
currentRatio = minRatio + (float) ((maxRatio - minRatio) * interpolatedTime);
}
LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
0, (float) currentRatio);
Dbg.d(TAG, "--- "+ currentRatio);
mScroll.setLayoutParams(param2);
root.requestLayout();
}
@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
@Override
public boolean willChangeBounds() {
return true;
}
}