本文整理汇总了Java中android.widget.FrameLayout.setOnTouchListener方法的典型用法代码示例。如果您正苦于以下问题:Java FrameLayout.setOnTouchListener方法的具体用法?Java FrameLayout.setOnTouchListener怎么用?Java FrameLayout.setOnTouchListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.FrameLayout
的用法示例。
在下文中一共展示了FrameLayout.setOnTouchListener方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FloatCamView
import android.widget.FrameLayout; //导入方法依赖的package包/类
public FloatCamView(FloatingCameraWindow window) {
super(window.mContext);
mWeakRef = new WeakReference<FloatingCameraWindow>(window);
// mLayoutInflater = LayoutInflater.from(context);
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);
mFPSText = (TextView) findViewById(R.id.fps_textview);
mInfoText = (TextView) findViewById(R.id.info_textview);
mFPSText.setVisibility(View.GONE);
mInfoText.setVisibility(View.GONE);
int colorMaxWidth = (int) (mWindowWidth* window.mScaleWidthRatio);
int colorMaxHeight = (int) (mWindowHeight * window.mScaleHeightRatio);
mColorView.getLayoutParams().width = colorMaxWidth;
mColorView.getLayoutParams().height = colorMaxHeight;
}
示例2: viewHolder
import android.widget.FrameLayout; //导入方法依赖的package包/类
public viewHolder(View itemView)
{
super(itemView);
itemPreview = (TextView)itemView.findViewById(R.id.card_preview);
itemContent = (TextView)itemView.findViewById(R.id.card_title); //the ID of the element can be found in front_page_card
itemContentFrame = (FrameLayout)itemView.findViewById(R.id.card);
projectEditButton = (ImageButton)itemView.findViewById(R.id.card_button);
context = itemView.getContext();
itemContentFrame.setOnTouchListener(adapterTouchListener);
projectEditButton.setOnClickListener(editButtonListener);
LayoutInflater layoutInflater = LayoutInflater.from(context);
//itemContentFrame.setBackgroundColor(Color.YELLOW);
//itemPreview.setBackgroundColor(Color.BLUE);
}
示例3: findViews
import android.widget.FrameLayout; //导入方法依赖的package包/类
private void findViews() {
if (init)
return;
if (surfaceRoot != null) {
touchLayout = surfaceRoot.findViewById(R.id.touch_zone);
touchLayout.setOnTouchListener(touchListener);
smallSizePreviewFrameLayout = (FrameLayout) surfaceRoot.findViewById(R.id.small_size_preview_layout);
smallSizePreviewLayout = (LinearLayout) surfaceRoot.findViewById(R.id.small_size_preview);
smallSizePreviewCoverImg = (ImageView) surfaceRoot.findViewById(R.id.smallSizePreviewCoverImg);
smallSizePreviewFrameLayout.setOnTouchListener(smallPreviewTouchListener);
largeSizePreviewLayout = (LinearLayout) surfaceRoot.findViewById(R.id.large_size_preview);
largeSizePreviewCoverLayout = surfaceRoot.findViewById(R.id.notificationLayout);
init = true;
}
}
示例4: onBindViewHolder
import android.widget.FrameLayout; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
VideoUserStatusHolder myHolder = ((VideoUserStatusHolder) holder);
final UserStatusData user = mUsers.get(position);
log.debug("onBindViewHolder " + position + " " + user + " " + myHolder + " " + myHolder.itemView + " " + mDefaultChildItem);
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() == mDefaultChildItem) {
SurfaceView target = user.mView;
VideoViewAdapterUtil.stripView(target);
holderView.addView(target, 0, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
VideoViewAdapterUtil.renderExtraData(mContext, user, myHolder);
}
示例5: onBindViewHolder
import android.widget.FrameLayout; //导入方法依赖的package包/类
@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() {
}
});
}
示例6: onBindViewHolder
import android.widget.FrameLayout; //导入方法依赖的package包/类
@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));
}
}
示例7: onCreate
import android.widget.FrameLayout; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setBackgroundColor(getResources().getColor(R.color.colorPhoneDark, getTheme()));
WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
//change this through preferences
int dragWidth = 20;
WindowManager.LayoutParams params = new WindowManager.LayoutParams(dragWidth, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT);
//change this through preferences
params.gravity = Gravity.START;
params.x = 0;
params.y = 0;
frameLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Toast.makeText(OverlayService.this, "yo", Toast.LENGTH_SHORT)
.show();
return false;
}
});
if (windowManager != null) {
windowManager.addView(frameLayout, params);
}
}
示例8: FloatCamView
import android.widget.FrameLayout; //导入方法依赖的package包/类
public FloatCamView(FloatingCameraWindow window) {
super(window.mContext);
mWeakRef = new WeakReference<FloatingCameraWindow>(window);
// mLayoutInflater = LayoutInflater.from(context);
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);
mFPSText = (TextView) findViewById(R.id.fps_textview);
mInfoText = (TextView) findViewById(R.id.info_textview);
mFPSText.setVisibility(View.GONE);
mInfoText.setVisibility(View.GONE);
int colorMaxWidth = (int) (mWindowWidth* window.mScaleWidthRatio);
int colorMaxHeight = (int) (mWindowHeight * window.mScaleHeightRatio);
mColorView.getLayoutParams().width = colorMaxWidth;
mColorView.getLayoutParams().height = colorMaxHeight;
mColorView.setScaleType(ImageView.ScaleType.FIT_XY);
}
示例9: onBindViewHolder
import android.widget.FrameLayout; //导入方法依赖的package包/类
@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 OnLiveDoubleTapListener(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));
}
}
示例10: onCreateView
import android.widget.FrameLayout; //导入方法依赖的package包/类
@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;
}
示例11: ActivityChooserView
import android.widget.FrameLayout; //导入方法依赖的package包/类
public ActivityChooserView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mModelDataSetOberver = new DataSetObserver() {
public void onChanged() {
super.onChanged();
ActivityChooserView.this.mAdapter.notifyDataSetChanged();
}
public void onInvalidated() {
super.onInvalidated();
ActivityChooserView.this.mAdapter.notifyDataSetInvalidated();
}
};
this.mOnGlobalLayoutListener = new OnGlobalLayoutListener() {
public void onGlobalLayout() {
if (!ActivityChooserView.this.isShowingPopup()) {
return;
}
if (ActivityChooserView.this.isShown()) {
ActivityChooserView.this.getListPopupWindow().show();
if (ActivityChooserView.this.mProvider != null) {
ActivityChooserView.this.mProvider.subUiVisibilityChanged(true);
return;
}
return;
}
ActivityChooserView.this.getListPopupWindow().dismiss();
}
};
this.mInitialActivityCount = 4;
TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.ActivityChooserView, defStyle, 0);
this.mInitialActivityCount = attributesArray.getInt(R.styleable.ActivityChooserView_initialActivityCount, 4);
Drawable expandActivityOverflowButtonDrawable = attributesArray.getDrawable(R.styleable.ActivityChooserView_expandActivityOverflowButtonDrawable);
attributesArray.recycle();
LayoutInflater.from(getContext()).inflate(R.layout.abc_activity_chooser_view, this, true);
this.mCallbacks = new Callbacks();
this.mActivityChooserContent = (LinearLayoutCompat) findViewById(R.id.activity_chooser_view_content);
this.mActivityChooserContentBackground = this.mActivityChooserContent.getBackground();
this.mDefaultActivityButton = (FrameLayout) findViewById(R.id.default_activity_button);
this.mDefaultActivityButton.setOnClickListener(this.mCallbacks);
this.mDefaultActivityButton.setOnLongClickListener(this.mCallbacks);
this.mDefaultActivityButtonImage = (ImageView) this.mDefaultActivityButton.findViewById(R.id.image);
FrameLayout expandButton = (FrameLayout) findViewById(R.id.expand_activities_button);
expandButton.setOnClickListener(this.mCallbacks);
expandButton.setOnTouchListener(new ForwardingListener(expandButton) {
public ListPopupWindow getPopup() {
return ActivityChooserView.this.getListPopupWindow();
}
protected boolean onForwardingStarted() {
ActivityChooserView.this.showPopup();
return true;
}
protected boolean onForwardingStopped() {
ActivityChooserView.this.dismissPopup();
return true;
}
});
this.mExpandActivityOverflowButton = expandButton;
this.mExpandActivityOverflowButtonImage = (ImageView) expandButton.findViewById(R.id.image);
this.mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable);
this.mAdapter = new ActivityChooserViewAdapter();
this.mAdapter.registerDataSetObserver(new DataSetObserver() {
public void onChanged() {
super.onChanged();
ActivityChooserView.this.updateAppearance();
}
});
Resources resources = context.getResources();
this.mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth));
}
示例12: onCreateView
import android.widget.FrameLayout; //导入方法依赖的package包/类
@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;
}
示例13: onCreateView
import android.widget.FrameLayout; //导入方法依赖的package包/类
@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;
}