Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void setUpResultView() {
- try{
- resultView = LayoutInflater.from(this).inflate(R.layout.result_layout_surface, null);
- final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
- WindowManager.LayoutParams.MATCH_PARENT,
- WindowManager.LayoutParams.WRAP_CONTENT,
- WindowManager.LayoutParams.TYPE_PHONE,
- WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
- PixelFormat.TRANSLUCENT);
- params.gravity = Gravity.TOP | Gravity.LEFT;
- //params.flags = BIND_ABOVE_CLIENT | BIND_NOT_FOREGROUND;
- params.x = 0;
- params.y = 0;
- SwipeLayout swipeLayout = (SwipeLayout)resultView.findViewById(R.id.swipe_layout);
- //set show mode.
- swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
- //add drag edge.(If the BottomView has 'layout_gravity' attribute, this line is unnecessary)
- swipeLayout.addDrag(SwipeLayout.DragEdge.Left, resultView.findViewById(R.id.bottom_wrapper));
- swipeLayout.addSwipeListener(swipeListener);
- resultView.setOnTouchListener(onTouchListener);
- windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
- windowManager.addView(resultView, params);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- SwipeLayout.SwipeListener swipeListener = new SwipeLayout.SwipeListener() {
- @Override
- public void onClose(SwipeLayout layout) {
- Logger.d("onClose");
- }
- @Override
- public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
- Logger.d("onUpdate");
- }
- @Override
- public void onStartOpen(SwipeLayout layout) {
- Logger.d("onStartOpen");
- }
- @Override
- public void onOpen(SwipeLayout layout) {
- Logger.d("onOpen");//when the BottomView totally show.
- }
- @Override
- public void onStartClose(SwipeLayout layout) {
- Logger.d("onStartClose");
- }
- @Override
- public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
- Logger.d("onHandRelease");//when user's hand released.
- }
- };
- View.OnTouchListener onTouchListener= new View.OnTouchListener() {
- private int lastAction;
- private int initialX;
- private int initialY;
- private float initialTouchX;
- private float initialTouchY;
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- Logger.d(event.getAction());
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- Logger.d("ACTION_DOWN");
- return true;
- case MotionEvent.ACTION_UP:
- Logger.d("ACTION_UP");
- return true;
- case MotionEvent.ACTION_MOVE:
- Logger.d("ACTION_MOVE");
- return true;
- }
- return false;
- }
- };
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:orientation="vertical"
- app:layout_behavior="@string/AUTO"
- app:layout_collapseParallaxMultiplier="1.0">
- <com.daimajia.swipe.SwipeLayout
- android:id="@+id/swipe_layout"
- android:layout_width="match_parent" android:layout_height="180dp">
- <!-- Bottom View Start-->
- <LinearLayout
- android:background="#660011ff"
- android:id="@+id/bottom_wrapper"
- android:layout_width="160dp"
- android:weightSum="1"
- android:layout_height="match_parent">
- <!--What you want to show-->
- </LinearLayout>
- <!-- Bottom View End-->
- <!-- Surface View Start -->
- <LinearLayout
- android:id="@+id/top_wrapper"
- android:padding="10dp"
- android:background="#a71919"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <!--What you want to show in SurfaceView-->
- </LinearLayout>
- <!-- Surface View End -->
- </com.daimajia.swipe.SwipeLayout>
- </LinearLayout>
Add Comment
Please, Sign In to add comment