ontouchlistener

SwipeRefreshLayout and Vertical ViewPager Touch Issues

梦想与她 提交于 2021-02-08 10:18:35
问题 I have a Activity with Custom SwipeRefreshLayout and a Vertical ViewPager which swipes vertically. (basically a deck of cards which can be refershed by using swipe to refresh). So Now when i try to swipe the Vertical Viewpager SwipeRefreshLayout handles the touch event and refresh the layout and the view pager's page does't move. Two things i tried but with no luck: Enable swipe to refresh layout only when user starts from the toolbar. MotionEvent.ACTION_DOWN event getY() gives toolbar's y

Touch listener on multiple Textviews?

孤者浪人 提交于 2021-02-08 09:58:56
问题 private TextView tv2; tv2=(TextView)findViewById(R.id.textView2); tv2.setOnTouchListener(new CustomTouchListener()); public class CustomTouchListener implements View.OnTouchListener { public boolean onTouch(View view, MotionEvent motionEvent) { switch(motionEvent.getAction()){ case MotionEvent.ACTION_DOWN: Hauteur.setTextSize(TypedValue.COMPLEX_UNIT_PX, 80); Hauteur.startAnimation(AnimationUtils.loadAnimation(recuperationJson.this, android.R.anim.slide_in_left)); break; case MotionEvent

Touch listener on multiple Textviews?

本小妞迷上赌 提交于 2021-02-08 09:58:10
问题 private TextView tv2; tv2=(TextView)findViewById(R.id.textView2); tv2.setOnTouchListener(new CustomTouchListener()); public class CustomTouchListener implements View.OnTouchListener { public boolean onTouch(View view, MotionEvent motionEvent) { switch(motionEvent.getAction()){ case MotionEvent.ACTION_DOWN: Hauteur.setTextSize(TypedValue.COMPLEX_UNIT_PX, 80); Hauteur.startAnimation(AnimationUtils.loadAnimation(recuperationJson.this, android.R.anim.slide_in_left)); break; case MotionEvent

How to Hide and Show Buttons on Alternate Touch Events

☆樱花仙子☆ 提交于 2021-02-07 10:59:27
问题 My activity displays images and i want to display two buttons when the user touch the screen, and to disappear these button on next touch. My activity file ImageViewPager.java is as follows: package com.pankajvatsa.testfeet; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.support.v4.view.ViewPager; import android.view.MotionEvent; import android.view.View; import android.widget.Button;

Using BottomSheetBehavior with a inner CoordinatorLayout

十年热恋 提交于 2021-01-20 14:12:28
问题 The design support library v. 23.2 introduced BottomSheetBehavior , which allows childs of a coordinator to act as bottom sheets (views draggable from the bottom of the screen). What I’d like to do is to have, as a bottom sheet view , the following view (the typical coordinator + collapsing stuff): <CoordinatorLayout app:layout_behavior=“@string/bottom_sheet_behavior”> <AppBarLayout> <CollapsingToolbarLayout> <ImageView /> </CollapsingToolbarLayout> </AppBarLayout> <NestedScrollView>

Using BottomSheetBehavior with a inner CoordinatorLayout

本秂侑毒 提交于 2021-01-20 14:09:18
问题 The design support library v. 23.2 introduced BottomSheetBehavior , which allows childs of a coordinator to act as bottom sheets (views draggable from the bottom of the screen). What I’d like to do is to have, as a bottom sheet view , the following view (the typical coordinator + collapsing stuff): <CoordinatorLayout app:layout_behavior=“@string/bottom_sheet_behavior”> <AppBarLayout> <CollapsingToolbarLayout> <ImageView /> </CollapsingToolbarLayout> </AppBarLayout> <NestedScrollView>

Android scale button on touch

天涯浪子 提交于 2020-11-28 07:47:12
问题 I know how to scale the button to a determinated value, but is there a way to increase/decrease the button size per time as long the user is touching it? Something like this: Button myButton = (Button)findViewById(R.id.myButton); myButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { // Some timer action here or is there a better way? v.setScaleX(v.getScaleX() + 0.1f); v

Cancel button press if user moves finger off button

血红的双手。 提交于 2020-01-23 12:25:55
问题 Here is my very standard button onTouchListener: b.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { b.setPressed(true); } if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) { b.setPressed(false); // Do the button action stuff here } return true; } }); When the user presses down on the button I set the button to "pressed". When the

How to know if two images are intersect while one image moving in android?

扶醉桌前 提交于 2020-01-22 21:28:40
问题 In my application, i am moving image around the screen by using onTouchListener . I have another two images in the same view. My problem is that, when the moving image, touches any of the other images, i need to perform a certain action (that means if images are intersected, then do something). How can this be achieved?.Please help me asap Thanks in Advance. 回答1: You should be able to use Rect.intersects(Rect, Rect) , like this example: Rect myViewRect = new Rect(); myView.getHitRect

How can I add OnClickListener to Drawable in EditText?

我是研究僧i 提交于 2020-01-14 09:18:48
问题 I have edittext and want to add to right "search" icon.. searchTxt.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.search, 0); But how can I add event for click this icon? searchTxt.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { Drawable co = ((TextView) v).getCompoundDrawables()[2]; if (event.getX() > v.getMeasuredWidth() - v.getPaddingRight() - co.getIntrinsicWidth()) { Datas.search = searchTxt.getText().toString(); startActivity