当前位置: 首页 > news >正文

网站流量少WordPress分类中文404错误

网站流量少,WordPress分类中文404错误,wikidot网站怎么做,wordpress后台显示英文Scroller VelocityTracker VelocityTracker 是一个速度跟踪器#xff0c;通过用户操作时#xff08;通常在 View 的 onTouchEvent 方法中#xff09;传进去一系列的 Event#xff0c;该类就可以计算出用户手指滑动的速度#xff0c;开发者可以方便地获取这些参数去做其他…Scroller VelocityTracker VelocityTracker 是一个速度跟踪器通过用户操作时通常在 View 的 onTouchEvent 方法中传进去一系列的 Event该类就可以计算出用户手指滑动的速度开发者可以方便地获取这些参数去做其他事情。或者手指滑动超过一定速度并松手就触发翻页。 CustomViewPager package com.flannery.androidtools.widgets;import android.content.Context; import android.graphics.Color; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.Scroller;/*** VelocityTracker is a concept commonly used in computer graphics, physics simulations, and user interface frameworks to calculate the velocity of an object or pointer based on its position over time. Its particularly useful for creating responsive and realistic interactions in applications like games or touch-based user interfaces.* In the context of Android development, VelocityTracker refers to a class provided by the Android framework. Its used to track the velocity of motion events, such as touch events, on the screen. This can be useful for implementing various gestures and animations that require knowledge of how quickly a user is moving their finger across the screen.* Heres a basic overview of how VelocityTracker works in Android:* Initialization: To use VelocityTracker, you need to create an instance of it and associate it with a specific motion event, typically the ACTION_MOVE events in the case of touch gestures.* Tracking: As the user interacts with the screen, you feed the VelocityTracker instance with the motion events, which contain the current position of the pointer. The VelocityTracker class calculates the velocity based on the change in position over time.* Velocity Retrieval: After youve collected enough motion events, you can retrieve the calculated velocity using the computeCurrentVelocity(int units) method. The units parameter allows you to specify the desired units for the velocity, such as pixels per second.** https://www.nhooo.com/note/qadf7m.html*/ public class CustomViewPager extends ViewGroup {private static final String TAG CustomViewPager.class.getSimpleName();private int screenWidth;private int screenHeight;private int lastMoveX 0;private Scroller scroller; // 滚动计算器private VelocityTracker velocityTracker; // 速度跟踪器private int MAX_VELOCITY 600;private int curScreen 0;public CustomViewPager(Context context) {super(context);init(context);}public CustomViewPager(Context context, AttributeSet attrs) {super(context, attrs);init(context);}public CustomViewPager(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);init(context);}private void init(Context context) {scroller new Scroller(context); // 初始化滚动计算器// 添加三个ViewLinearLayout layout1 new LinearLayout(context);layout1.setBackgroundColor(Color.RED);addView(layout1);LinearLayout layout2 new LinearLayout(context);layout2.setBackgroundColor(Color.GREEN);addView(layout2);LinearLayout layout3 new LinearLayout(context);layout3.setBackgroundColor(Color.BLUE);addView(layout3);}Overridepublic boolean onTouchEvent(MotionEvent event) {Log.i(TAG, onTouchEvent: onTouchEvent event);if (velocityTracker null) {velocityTracker VelocityTracker.obtain(); // 初始化滚动速度跟踪器}velocityTracker.addMovement(event);int x (int) event.getX();switch (event.getAction()) {case MotionEvent.ACTION_DOWN:lastMoveX x; // 记录下按下的点break;case MotionEvent.ACTION_MOVE:int dis lastMoveX - x; // 移动的偏移量Log.i(TAG, onTouchEvent: dis dis);scrollBy(dis, 0); // 位置滚动lastMoveX x;break;case MotionEvent.ACTION_UP:velocityTracker.computeCurrentVelocity(1000); // 计算需要的位置int velocityX (int) velocityTracker.getXVelocity(); // X轴上的速度if (velocityX MAX_VELOCITY curScreen 0) {jump2Screen(curScreen - 1);} else if (velocityX -MAX_VELOCITY curScreen getChildCount() - 1) {jump2Screen(curScreen 1);} else {int screen (getScrollX() screenWidth / 2) / screenWidth;jump2Screen(screen);}if (velocityTracker ! null) {velocityTracker.recycle();velocityTracker null;}break;}return true;}public void jump2Screen(int screen) {curScreen screen;if (curScreen 0) {curScreen 0;}if (curScreen getChildCount() - 1) {curScreen getChildCount() - 1;}int dis curScreen * screenWidth - getScrollX();scroller.startScroll(getScrollX(), 0, dis, 0); // 开始滚动invalidate();}Overridepublic void computeScroll() {super.computeScroll();if (scroller.computeScrollOffset()) { // 是否处于偏移量的位置scrollTo(scroller.getCurrX(), 0); // 滚动到指定的位置postInvalidate(); // 继续滚动}}Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {super.onMeasure(widthMeasureSpec, heightMeasureSpec);screenWidth MeasureSpec.getSize(widthMeasureSpec);screenHeight MeasureSpec.getSize(heightMeasureSpec);setMeasuredDimension(screenWidth, screenHeight);// 给子View设置大小for (int i 0; i getChildCount(); i) {View view getChildAt(i);view.measure(screenWidth, screenHeight);}}Overrideprotected void onLayout(boolean changed, int l, int t, int r, int b) {int leftWidth 0;// 给子View排班for (int i 0; i getChildCount(); i) {View view getChildAt(i);view.layout(leftWidth, 0, leftWidth screenWidth, screenHeight);leftWidth leftWidth screenWidth;}} }资料 Android scrollTo、scrollBy、以及scroller详解 Android Scroller详解 Android自定义ViewPager实例 Android View 的滚动原理和 Scroller、VelocityTracker 类的使用
http://www.w-s-a.com/news/432193/

相关文章:

  • 网站设计报告总结南宁商城网站推广公司
  • 淘宝做店招的网站免费网站建设自助建站
  • 重庆工信部网站绵阳公司网站建设
  • 购物网站开发流程制作企业网页
  • 定州哪里可以做网站建设项目环境影响登记表备案系统网站
  • 网站建设费属于广告费小猪网站怎么做的
  • 国内优秀设计网站站长哈尔滨微网站建设
  • 如何建设一个优秀的电商网站沐风seo
  • 从零开始学网站建设知乎安防网站下载
  • 打开网站弹出qq应用软件有哪些
  • 温州网站建设seo网站 如何做 中英文切换
  • 聊城做网站的公司资讯信阳 网站建设
  • 天津市工程建设交易网站查汗国珠海 网页设计
  • 龙果学院大型网站稳定性建设汾阳做网站
  • 湖北 个人网站备案时间域名查询备案查询
  • 网站推广方式校园网站怎么建
  • 长沙seo网站排名怎么在百度发帖
  • 织梦贷款网站模板做印章网站
  • 彭州做网站上海百度网络推广
  • 广州网站搭建快速提升网站排名荧光字网站
  • 15年做那些网站能致富做seo是什么意思
  • 各电商网站的特点网站制作2007
  • 用html做一号店网站怎么做公众号注册平台官网
  • 做盈利网站怎么备案vs做网站如何调试
  • 嘉兴做营销型网站廊坊做网站外包
  • 双语网站模板常州做网站的公司
  • 广州市车管所网站建设全国做网站公司前十名
  • 太原手手工网站建设公司视频直播服务
  • 雷达图 做图网站wordpress首页怎么美化
  • 四川做网站设计公司价格vip解析网站怎么做的