Context menu - few fixes

This commit is contained in:
Alexey Kulish 2015-09-08 20:01:25 +03:00
parent 748337ada6
commit bb588f0816
2 changed files with 8 additions and 12 deletions

View file

@ -2,12 +2,12 @@
<LinearLayout android:id="@+id/context_menu_layout" <LinearLayout android:id="@+id/context_menu_layout"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/context_menu_shadow_layout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
@ -24,12 +24,12 @@
android:id="@+id/context_menu_main" android:id="@+id/context_menu_main"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:background="?attr/bg_map_context_menu" android:background="?attr/bg_map_context_menu"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/context_menu_top_view" android:id="@+id/context_menu_top_view"
android:baselineAligned="false"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">

View file

@ -12,7 +12,6 @@ import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -85,6 +84,8 @@ public class MapContextMenuFragment extends Fragment {
View topView = view.findViewById(R.id.context_menu_top_view); View topView = view.findViewById(R.id.context_menu_top_view);
mainView = view.findViewById(R.id.context_menu_main); mainView = view.findViewById(R.id.context_menu_main);
//LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(400));
//mainView.setLayoutParams(lp);
topView.setOnTouchListener(new View.OnTouchListener() { topView.setOnTouchListener(new View.OnTouchListener() {
@ -100,21 +101,16 @@ public class MapContextMenuFragment extends Fragment {
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
float y = event.getY(); float y = event.getY();
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mainView.getLayoutParams(); mainView.setY(mainView.getY() + (y - dy));
float top = lp.topMargin + (y - dy);
if (top < 0) {
lp.topMargin = (int) top;
mainView.setLayoutParams(lp);
}
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL:
float posY = view.getHeight() - mainViewHeight; float posY = view.getHeight() - mainViewHeight;
if (mainView.getY() != posY) { if (mainView.getY() != posY)
mainView.animate().y(posY).setDuration(200).setInterpolator(new DecelerateInterpolator()).start(); mainView.animate().y(posY).setDuration(200).setInterpolator(new DecelerateInterpolator()).start();
}
break; break;
} }