Java Code Examples for android.widget.FrameLayout#setOnTouchListener()
The following examples show how to use
android.widget.FrameLayout#setOnTouchListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatingCameraWindow.java From android-hpe with MIT License | 6 votes |
public FloatCamView(FloatingCameraWindow window) { super(window.mContext); mWeakRef = new WeakReference<FloatingCameraWindow>(window); mLayoutInflater = (LayoutInflater) window.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); FrameLayout body = (FrameLayout) this; body.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return false; } }); View floatView = mLayoutInflater.inflate(R.layout.cam_window_view, body, true); mColorView = (ImageView) findViewById(R.id.imageView_c); int colorMaxWidth = (int) (mWindowWidth * window.mScaleWidthRatio); int colorMaxHeight = (int) (mWindowHeight * window.mScaleHeightRatio); mColorView.getLayoutParams().width = colorMaxWidth; mColorView.getLayoutParams().height = colorMaxHeight; }
Example 2
Source File: ZoomFragment.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRootView = (FrameLayout) inflater.inflate(R.layout.rebound_zoom_fragment, container, false); mImageView = mRootView.findViewById(R.id.image_view); mRootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mScaleSpring.setEndValue(1); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mScaleSpring.setEndValue(0); break; } return true; } }); return mRootView; }
Example 3
Source File: ZoomFragment.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mRootView = (FrameLayout) inflater.inflate(R.layout.rebound_zoom_fragment, container, false); mImageView = mRootView.findViewById(R.id.image_view); mRootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mScaleSpring.setEndValue(1); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mScaleSpring.setEndValue(0); break; } return true; } }); return mRootView; }
Example 4
Source File: VideoViewAdapter.java From FuAgoraDemoDroid with MIT License | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { VideoUserStatusHolder myHolder = ((VideoUserStatusHolder) holder); final VideoStatusData user = mUsers.get(position); Log.d("VideoViewAdapter", "onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView); log.debug("onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView); FrameLayout holderView = (FrameLayout) myHolder.itemView; if (holderView.getChildCount() == 0) { SurfaceView target = user.mView; stripSurfaceView(target); holderView.addView(target, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } holderView.setOnTouchListener(new OnDoubleTapListener(mContext) { @Override public void onDoubleTap(View view, MotionEvent e) { if (mListener != null) { mListener.onItemDoubleClick(view, user); } } @Override public void onSingleTapUp() { } }); }
Example 5
Source File: GridVideoViewContainerAdapter.java From FuAgoraDemoDroid with MIT License | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { VideoUserStatusHolder myHolder = ((VideoUserStatusHolder) holder); final VideoStatusData user = mUsers.get(position); log.debug("onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView); FrameLayout holderView = (FrameLayout) myHolder.itemView; holderView.setOnTouchListener(new OnDoubleTapListener(mContext) { @Override public void onDoubleTap(View view, MotionEvent e) { if (mListener != null) { mListener.onItemDoubleClick(view, user); } } @Override public void onSingleTapUp() { } }); if (holderView.getChildCount() == 0) { SurfaceView target = user.mView; stripSurfaceView(target); holderView.addView(target, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } }
Example 6
Source File: TapToMoveDemoFragment.java From android_additive_animations with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = (FrameLayout) inflater.inflate(R.layout.fragment_tap_to_move_demo, container, false); mTouchView = rootView.findViewById(R.id.touch_view); animatedView = rootView.findViewById(R.id.animated_view); rootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN) { AdditiveAnimator.cancelAnimations(mTouchView); mTouchView.setAlpha(1); mTouchView.setX(event.getX() - mTouchView.getWidth()/2); mTouchView.setY(event.getY() - mTouchView.getHeight()/2); if(AdditiveAnimationsShowcaseActivity.ADDITIVE_ANIMATIONS_ENABLED) { AdditiveAnimator.animate(animatedView) .centerX(event.getX()) // uncomment the next line to see how you can use a different interpolator for each property! // .switchInterpolator(new BounceInterpolator()) .centerY(event.getY()) .start(); } else { animatedView.animate().setInterpolator(EaseInOutPathInterpolator.create()).setDuration(1000) .x(event.getX() - animatedView.getWidth() / 2) .y(event.getY() - animatedView.getHeight() / 2) .start(); } } if(event.getAction() == MotionEvent.ACTION_UP) { AdditiveAnimator.animate(mTouchView, 100).alpha(0).start(); } return true; } }); return rootView; }
Example 7
Source File: ReboundDemoActivity.java From AndroidAnimations with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rebound_demo); rootView = (FrameLayout) findViewById(R.id.root_view); imageView = rootView.findViewById(R.id.image_view); // Create the animation spring. scaleSpring = springSystem.createSpring(); // Add an OnTouchListener to the root view. rootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // When pressed start solving the spring to 1. scaleSpring.setEndValue(1); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: // When released start solving the spring to 0. scaleSpring.setEndValue(0); break; } return true; } }); }
Example 8
Source File: KonamiCode.java From KonamiCode with Apache License 2.0 | 5 votes |
/** * install - installs all Konami Code components into the target */ public KonamiCode install() { View currentView = rootView.getChildAt(0); rootView.removeView(currentView); //match parent params FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ); FrameLayout gestureDelegate = new FrameLayout(context); gestureDelegate.addView(currentView, layoutParams); //necessary view that passes all touch events up to the parent viewgroup gestureDelegate.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); KonamiCodeLayout konamiCodeLayout = new KonamiCodeLayout(context); konamiCodeLayout.addView(gestureDelegate); rootView.addView(konamiCodeLayout, layoutParams); konamiCodeLayout.setCallback(callback); return new KonamiCode(this); }
Example 9
Source File: DialogStack.java From Dashchan with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public DialogStack(Context context, ExpandedScreen expandedScreen) { this.context = context; styledContext = new ContextThemeWrapper(context, ResourceUtils.getResourceId(context, android.R.attr.dialogTheme, 0)); this.expandedScreen = expandedScreen; rootView = new FrameLayout(context); rootView.setOnTouchListener(this); TypedArray typedArray = styledContext.obtainStyledAttributes(new int[] {android.R.attr.backgroundDimAmount}); dimAmount = typedArray.getFloat(0, 0.6f); typedArray.recycle(); }
Example 10
Source File: AnimationChainingDemoFragment.java From android_additive_animations with Apache License 2.0 | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = (FrameLayout) inflater.inflate(R.layout.fragment_tap_to_move_demo, container, false); animatedView = rootView.findViewById(R.id.animated_view); rootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, final MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN) { int offset = DpConverter.converDpToPx(150); if(AdditiveAnimationsShowcaseActivity.ADDITIVE_ANIMATIONS_ENABLED) { AdditiveAnimator.animate(animatedView) .centerX(event.getX()).centerY(event.getY()) .then() // execute the following animations after the previous ones have finished .centerX(event.getX() - offset).centerY(event.getY() - offset) .start(); } else { PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, event.getX() - animatedView.getWidth() / 2); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, event.getY() - animatedView.getHeight() / 2); ObjectAnimator animator1 = ObjectAnimator.ofPropertyValuesHolder(animatedView, pvhX, pvhY); PropertyValuesHolder pvhX2 = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, (event.getX() - animatedView.getWidth() / 2) - offset); PropertyValuesHolder pvhY2 = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, (event.getY() - animatedView.getHeight() / 2) - offset); ObjectAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(animatedView, pvhX2, pvhY2); AnimatorSet animators = new AnimatorSet(); animators.playSequentially(animator1, animator2); animators.setDuration(2000); animators.setInterpolator(EaseInOutPathInterpolator.create()); animators.start(); } } return true; } }); return rootView; }
Example 11
Source File: MoveAlongPathDemoFragment.java From android_additive_animations with Apache License 2.0 | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = (FrameLayout) inflater.inflate(R.layout.fragment_move_along_path_demo, container, false); animatedView = rootView.findViewById(R.id.animated_view); rootView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_DOWN) { if(AdditiveAnimationsShowcaseActivity.ADDITIVE_ANIMATIONS_ENABLED) { AdditiveAnimator.animate(animatedView) .x(event.getX()) .y(event.getY()) .start(); } } return true; } }); // wait for rootView to layout itself so we can get its center rootView.post(new Runnable() { @Override public void run() { if (AdditiveAnimationsShowcaseActivity.ADDITIVE_ANIMATIONS_ENABLED) { // small circle final Path path1 = new Path(); path1.addCircle(rootView.getWidth() / 2, rootView.getHeight() / 2, circleRadius, Path.Direction.CW); AdditiveAnimator.animate(animatedView).setInterpolator(new LinearInterpolator()) .xyAlongPath(path1) .setRepeatCount(ValueAnimator.INFINITE) .start(); // another circle which also updates rotation to better show where on the path we are final Path path2 = new Path(); path2.addCircle(rootView.getWidth() / 2, rootView.getHeight() / 2, rootView.getWidth() / 3, Path.Direction.CW); AdditiveAnimator.animate(animatedView).setDuration(3200).setInterpolator(new LinearInterpolator()) .xyRotationAlongPath(path2) .setRepeatCount(ValueAnimator.INFINITE) .start(); } else { // TODO } } }); return rootView; }
Example 12
Source File: Window.java From FloatUtil with MIT License | 4 votes |
public Window(WindowWrapper windowWrapper) { super(windowWrapper.getContext()); mContext = windowWrapper.getContext(); mWindowWrapper = windowWrapper; this.id = mWindowWrapper.WindowId; this.originalParams = windowWrapper.onRequestLayoutParams(); this.flags = windowWrapper.onRequestWindowFlags(); this.touchInfo = new TouchInfo(); touchInfo.ratio = (float) originalParams.width / originalParams.height; this.data = new Bundle(); // create the window contents FrameLayout content = new FrameLayout(mContext); content.setId(android.R.id.content); addView(content); mLongPressRunnable = new Runnable() { @Override public void run() { if (mWindowWrapper.handleLongClick()){ touchInfo.isLongPress = true; mWindowWrapper.onLongPressed(); } } }; content.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // pass all touch events to the implementation boolean consumed = false; final StandOutWindowManager windowManager = mWindowWrapper.getWindowManager(); dispatchLongPress(event); // handle move and bring to front consumed = windowManager.onTouchHandleMove(Window.this, v, event) || consumed; // alert implementation consumed = mWindowWrapper.onTouchBody(Window.this, v, event) || consumed; return consumed; } }); // attach the view corresponding to the id from the // implementation windowWrapper.onCreateAndAttachView(content); // make sure the implementation attached the view if (content.getChildCount() == 0) { Log.e(TAG, "You must attach your view to the given frame in onCreateAndAttachView()"); } // attach the existing tag from the frame to the window setTag(content.getTag()); windowWrapper.isCreated = true; }
Example 13
Source File: ExpandableLayoutItem.java From BaseProject with Apache License 2.0 | 4 votes |
private void init(final Context context, AttributeSet attrs) { final View rootView = View.inflate(context, R.layout.view_expandable, this); headerLayout = (FrameLayout) rootView.findViewById(R.id.view_expandable_headerlayout); final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ExpandableLayout); final int headerID = typedArray.getResourceId(R.styleable.ExpandableLayout_el_headerLayout, -1); final int contentID = typedArray.getResourceId(R.styleable.ExpandableLayout_el_contentLayout, -1); contentLayout = (FrameLayout) rootView.findViewById(R.id.view_expandable_contentLayout); if (headerID == -1 || contentID == -1) throw new IllegalArgumentException("HeaderLayout and ContentLayout cannot be null!"); if (isInEditMode()) return; duration = typedArray.getInt(R.styleable.ExpandableLayout_el_duration, getContext().getResources().getInteger(android.R.integer.config_shortAnimTime)); final View headerView = View.inflate(context, headerID, null); headerView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); headerLayout.addView(headerView); setTag(ExpandableLayoutItem.class.getName()); final View contentView = View.inflate(context, contentID, null); contentView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); contentLayout.addView(contentView); contentLayout.setVisibility(GONE); headerLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (isOpened() && event.getAction() == MotionEvent.ACTION_UP) { hide(); closeByUser = true; } return isOpened() && event.getAction() == MotionEvent.ACTION_DOWN; } }); }
Example 14
Source File: MainActivity.java From Chimee with MIT License | 4 votes |
@SuppressLint("ClickableViewAccessibility") private void addGestureDetectorToTopLayout() { FrameLayout topLayout = findViewById(R.id.flTop); mScaleDetector = new ScaleGestureDetector(this, new ScaleListener()); topLayout.setOnTouchListener(touchListener); }
Example 15
Source File: ExpandableLayoutItem.java From ExpandableLayout with MIT License | 4 votes |
private void init(final Context context, AttributeSet attrs) { final View rootView = View.inflate(context, R.layout.view_expandable, this); headerLayout = (FrameLayout) rootView.findViewById(R.id.view_expandable_headerlayout); final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ExpandableLayout); final int headerID = typedArray.getResourceId(R.styleable.ExpandableLayout_el_headerLayout, -1); final int contentID = typedArray.getResourceId(R.styleable.ExpandableLayout_el_contentLayout, -1); contentLayout = (FrameLayout) rootView.findViewById(R.id.view_expandable_contentLayout); if (headerID == -1 || contentID == -1) throw new IllegalArgumentException("HeaderLayout and ContentLayout cannot be null!"); if (isInEditMode()) return; duration = typedArray.getInt(R.styleable.ExpandableLayout_el_duration, getContext().getResources().getInteger(android.R.integer.config_shortAnimTime)); final View headerView = View.inflate(context, headerID, null); headerView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); headerLayout.addView(headerView); setTag(ExpandableLayoutItem.class.getName()); final View contentView = View.inflate(context, contentID, null); contentView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); contentLayout.addView(contentView); contentLayout.setVisibility(GONE); headerLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (isOpened() && event.getAction() == MotionEvent.ACTION_UP) { hide(); closeByUser = true; } return isOpened() && event.getAction() == MotionEvent.ACTION_DOWN; } }); }
Example 16
Source File: MaterialContentOverflow.java From MaterialContentOverflow with Apache License 2.0 | 3 votes |
public void makeView(Context context, int buttonDrawable, int buttonColor, int contentColor, int buttonPosition) { FrameLayout contentFrame = createContentFrame(context, contentColor); FloatingActionButton fab = createFab(context, buttonDrawable, buttonColor, buttonPosition); overflowGestureListener = new OverflowGestureListener(this); fab.setOnTouchListener(overflowGestureListener.getMotionEvent()); contentFrame.setOnTouchListener(overflowGestureListener.getMotionEvent()); }