protected internal override void ComputeRender(float renderProgress) { if (mCurrentBounds.IsEmpty) { return; } if (mMotherMovePath.IsEmpty) { mMotherMovePath.Set(CreateMotherMovePath()); mMotherMovePathMeasure.SetPath(mMotherMovePath, false); mChildMovePath.Set(CreateChildMovePath()); mChildMovePathMeasure.SetPath(mChildMovePath, false); } //mother oval float motherMoveProgress = MOTHER_MOVE_INTERPOLATOR.GetInterpolation(renderProgress); mMotherMovePathMeasure.GetPosTan(GetCurrentMotherMoveLength(motherMoveProgress), mMotherPosition, null); mMotherOvalHalfWidth = mMaxMotherOvalSize; mMotherOvalHalfHeight = mMaxMotherOvalSize * GetMotherShapeFactor(motherMoveProgress); //child Oval float childMoveProgress = CHILD_MOVE_INTERPOLATOR.GetInterpolation(renderProgress); mChildMovePathMeasure.GetPosTan(GetCurrentChildMoveLength(childMoveProgress), mChildPosition, null); SetupChildParams(childMoveProgress); mRotateDegrees = (int)(DensityUtil.Radian2Degrees(Math.Atan((mMotherPosition[1] - mChildPosition[1]) / (mMotherPosition[0] - mChildPosition[0])))); mRevealCircleRadius = GetCurrentRevealCircleRadius(renderProgress); mCurrentOvalColor = GetCurrentOvalColor(renderProgress); mCurrentBackgroundColor = GetCurrentBackgroundColor(renderProgress); }
private void Init(Context context) { mTextSize = DensityUtil.Dip2Px(context, DEFAULT_TEXT_SIZE); Width = DensityUtil.Dip2Px(context, DEFAULT_WIDTH); Height = DensityUtil.Dip2Px(context, DEFAULT_HEIGHT); mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_WIDTH); mGasTubeWidth = DensityUtil.Dip2Px(context, DEFAULT_GAS_TUBE_WIDTH); mGasTubeHeight = DensityUtil.Dip2Px(context, DEFAULT_GAS_TUBE_HEIGHT); mCannulaWidth = DensityUtil.Dip2Px(context, DEFAULT_CANNULA_WIDTH); mCannulaHeight = DensityUtil.Dip2Px(context, DEFAULT_CANNULA_HEIGHT); mCannulaOffsetY = DensityUtil.Dip2Px(context, DEFAULT_CANNULA_OFFSET_Y); mCannulaMaxOffsetY = DensityUtil.Dip2Px(context, DEFAULT_CANNULA_MAX_OFFSET_Y); mPipeBodyWidth = DensityUtil.Dip2Px(context, DEFAULT_PIPE_BODY_WIDTH); mPipeBodyHeight = DensityUtil.Dip2Px(context, DEFAULT_PIPE_BODY_HEIGHT); mBalloonWidth = DensityUtil.Dip2Px(context, DEFAULT_BALLOON_WIDTH); mBalloonHeight = DensityUtil.Dip2Px(context, DEFAULT_BALLOON_HEIGHT); mRectCornerRadius = DensityUtil.Dip2Px(context, DEFAULT_RECT_CORNER_RADIUS); mBalloonColor = DEFAULT_BALLOON_COLOR; mGasTubeColor = DEFAULT_GAS_TUBE_COLOR; mCannulaColor = DEFAULT_CANNULA_COLOR; mPipeBodyColor = DEFAULT_PIPE_BODY_COLOR; mProgressText = 10 + PERCENT_SIGN; Duration = ANIMATION_DURATION; }
private void Init(Context context) { mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_WIDTH); mCenterRadius = DensityUtil.Dip2Px(context, DEFAULT_CENTER_RADIUS); mLevelSwipeDegrees = new float[3]; mLevelColors = DEFAULT_LEVEL_COLORS; }
private void Init(Context context) { mColors = DEFAULT_COLORS; mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_WIDTH); mCenterRadius = DensityUtil.Dip2Px(context, DEFAULT_CENTER_RADIUS); InitStrokeInSet(Width, Height); }
private void Init(Context context) { mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_WIDTH); mCenterRadius = DensityUtil.Dip2Px(context, DEFAULT_CENTER_RADIUS); mSkipBallSize = DensityUtil.Dip2Px(context, DEFAULT_SKIP_BALL_RADIUS); mColor = DEFAULT_COLOR; mBallColor = DEFAULT_BALL_COLOR; }
private void Init(Context context) { mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_WIDTH); mCenterRadius = DensityUtil.Dip2Px(context, DEFAULT_CENTER_RADIUS); mDanceBallRadius = DensityUtil.Dip2Px(context, DEFAULT_DANCE_BALL_RADIUS); Color = DEFAULT_COLOR; SetInsets((int)Width, (int)Height); Duration = ANIMATION_DURATION; }
private void Init(Context context) { mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_WIDTH); mCenterRadius = DensityUtil.Dip2Px(context, DEFAULT_CENTER_RADIUS); mColor = DEFAULT_COLOR; mGearCount = GEAR_COUNT; mGearSwipeDegrees = DEFAULT_GEAR_SWIPE_DEGREES; }
private void Init(Context context) { Width = DensityUtil.Dip2Px(context, DEFAULT_WIDTH); Height = DensityUtil.Dip2Px(context, DEFAULT_HEIGHT); mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_WIDTH); mWaitCircleRadius = DensityUtil.Dip2Px(context, WAIT_CIRCLE_RADIUS); mTopColor = Color.White; mMiddleColor = Color.ParseColor("#FFF3C742"); mBottomColor = Color.ParseColor("#FF89CC59"); Duration = ANIMATION_DURATION; }
private void Init(Context context) { Width = DensityUtil.Dip2Px(context, DEFAULT_WIDTH); Height = DensityUtil.Dip2Px(context, DEFAULT_HEIGHT); mBallRadius = DensityUtil.Dip2Px(context, DEFAULT_BALL_RADIUS); mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_WIDTH); mColor = DEFAULT_COLOR; Duration = ANIMATION_DURATION; mBallCount = DEFAULT_CIRCLE_COUNT; mBallInterval = mBallRadius; }
private void Initialize() { Element.Circle_r = DensityUtil.Dp2px(Context, 3f); Element.Circle_R = DensityUtil.Dp2px(Context, 20f); Element.Distance = DensityUtil.Dp2px(Context, 40f); var Length = 3 * Element.Circle_R * 2 + Element.Distance * 2; int MyWidth = DensityUtil.Dp2px(Context, (float)Element.WidthRequest); int MyPadding = (int)((MyWidth - Length) / 2); Element.X_Zero = MyPadding + Element.Circle_R; Element.Y_Zero = MyPadding + Element.Circle_R; paint = new Paint(); SetOnTouchListener(this); Element.InitPointList(); PostInvalidate(); }
private void Init(Context context) { mBallRadius = DensityUtil.Dip2Px(context, DEFAULT_BALL_RADIUS); Width = DensityUtil.Dip2Px(context, DEFAULT_WIDTH); Height = DensityUtil.Dip2Px(context, DEFAULT_HEIGHT); mOvalVerticalRadius = DensityUtil.Dip2Px(context, DEFAULT_OVAL_HEIGHT); mColors = DEFAULT_COLORS; mPositions = DEFAULT_POSITIONS; mBallCount = DEFAULT_BALL_COUNT; //mBallMoveYOffsets = mBallQuadCoefficient * mBallMoveXOffsets ^ 2 // ==> if mBallMoveYOffsets == mBallMoveXOffsets // ==> mBallQuadCoefficient = 1.0f / mBallMoveXOffsets; mBallMoveXOffsets = 1.5f * (2 * mBallRadius); mBallQuadCoefficient = 1.0f / mBallMoveXOffsets; }
private void Init(Context context) { Width = DensityUtil.Dip2Px(context, DEFAULT_WIDTH); Height = DensityUtil.Dip2Px(context, DEFAULT_HEIGHT); mRiverBankWidth = DensityUtil.Dip2Px(context, DEFAULT_RIVER_BANK_WIDTH); mPathFullLineSize = DensityUtil.Dip2Px(context, DEFAULT_PATH_FULL_LINE_SIZE); mPathDottedLineSize = DensityUtil.Dip2Px(context, DEFAULT_PATH_DOTTED_LINE_SIZE); mFishWidth = DensityUtil.Dip2Px(context, DEFAULT_FISH_WIDTH); mFishHeight = DensityUtil.Dip2Px(context, DEFAULT_FISH_HEIGHT); mFishEyeSize = DensityUtil.Dip2Px(context, DEFAULT_FISH_EYE_SIZE); mRiverWidth = DensityUtil.Dip2Px(context, DEFAULT_RIVER_WIDTH); mRiverHeight = DensityUtil.Dip2Px(context, DEFAULT_RIVER_HEIGHT); mColor = DEFAULT_COLOR; Duration = ANIMATION_DURATION; }
private void Init(Context context) { Width = DensityUtil.Dip2Px(context, DEFAULT_WIDTH); Height = DensityUtil.Dip2Px(context, DEFAULT_HEIGHT); mEyeEdgeWidth = DensityUtil.Dip2Px(context, DEFAULT_EYE_EDGE_WIDTH); mEyeInterval = DensityUtil.Dip2Px(context, DEFAULT_EYE_CIRCLE_INTERVAL); mEyeBallOffsetY = DensityUtil.Dip2Px(context, DEFAULT_EYE_BALL_OFFSET_Y); mEyeCircleRadius = DensityUtil.Dip2Px(context, DEFAULT_EYE_CIRCLE_RADIUS); mMaxEyeJumptDistance = DensityUtil.Dip2Px(context, DEFAULT_MAX_EYE_JUMP_DISTANCE); mAboveRadianEyeOffsetX = DensityUtil.Dip2Px(context, DEFAULT_ABOVE_RADIAN_EYE_CIRCLE_OFFSET); mEyeBallWidth = DensityUtil.Dip2Px(context, DEFAULT_EYE_BALL_WIDTH); mEyeBallHeight = DensityUtil.Dip2Px(context, DEFAULT_EYE_BALL_HEIGHT); mColor = DEFAULT_COLOR; Duration = ANIMATION_DURATION; }
private void Init(Context context) { mTextSize = DensityUtil.Dip2Px(context, DEFAULT_TEXT_SIZE); Width = DensityUtil.Dip2Px(context, DEFAULT_Width); Height = DensityUtil.Dip2Px(context, DEFAULT_Height); mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_Width); mBottleWidth = DensityUtil.Dip2Px(context, DEFAULT_BOTTLE_Width); mBottleHeight = DensityUtil.Dip2Px(context, DEFAULT_BOTTLE_Height); mWaterLowestPointToBottleneckDistance = DensityUtil.Dip2Px(context, WATER_LOWEST_POINT_TO_BOTTLENECK_DISTANCE); mBottleColor = DEFAULT_BOTTLE_COLOR; mWaterColor = DEFAULT_WATER_COLOR; mWaveCount = DEFAULT_WAVE_COUNT; Duration = ANIMATION_DURATION; }
private void Init(Context context) { Width = DensityUtil.Dip2Px(context, DEFAULT_WIDTH); Height = DensityUtil.Dip2Px(context, DEFAULT_HEIGHT); mMaxMotherOvalSize = DensityUtil.Dip2Px(context, MAX_MATHER_OVAL_SIZE); mBasicChildOvalRadius = DensityUtil.Dip2Px(context, MIN_CHILD_OVAL_RADIUS); mOvalColor = DEFAULT_OVAL_COLOR; mOvalDeepColor = DEFAULT_OVAL_DEEP_COLOR; mBackgroundColor = DEFAULT_BACKGROUND_COLOR; mBackgroundDeepColor = DEFAULT_BACKGROUND_DEEP_COLOR; mMotherOvalHalfWidth = mMaxMotherOvalSize; mMotherOvalHalfHeight = mMaxMotherOvalSize; mMaxRevealCircleRadius = (int)(Math.Sqrt(Width * Width + Height * Height) / 2 + 1); Duration = ANIMATION_DURATION; }
public override View GetView(int position, View convertView, ViewGroup parent) { var functionName = GetItem(position).FunctionName; int pictureSrc = GetItem(position).PictureSrc; LayoutInflater inflater = LayoutInflater.From(Context); View root = inflater.Inflate(_resourceId, null); TextView tv = (TextView)root.FindViewById(Resource.Id.function_tv); View v1 = (View)root.FindViewById(Resource.Id.item_rel); ImageView iv = (ImageView)root .FindViewById(Resource.Id.function_iv); tv.Text = functionName; iv.SetImageResource(pictureSrc); // LogUtils.e("potter", "gridviewheight:" + gridview.getHeight()); LayoutParams layoutParams = v1.LayoutParameters; layoutParams.Height = (int)((_gridview.Height - DensityUtil.Dip2px( Context, 4.0f)) / 3); return(root); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_practice_weibo); mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar); mToolbar.NavigationClick += (sender, e) => { Finish(); }; //状态栏透明和间距处理 StatusBarUtil.immersive(this); StatusBarUtil.setPaddingSmart(this, mToolbar); parallax = FindViewById(Resource.Id.parallax); var buttonBar = FindViewById(Resource.Id.buttonBarLayout); var scrollView = FindViewById <NestedScrollView>(Resource.Id.scrollView); var refreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; refreshLayout.SetOnMultiPurposeListener(new CustomSimpleMultiPurposeListener(this)); int lastScrollY = 0; int h = DensityUtil.Dp2px(170); int color = ContextCompat.GetColor(ApplicationContext, Resource.Color.colorPrimary) & 0x00ffffff; scrollView.ScrollChange += (sender, e) => { var scrollX = e.ScrollX; var scrollY = e.ScrollY; if (lastScrollY < h) { scrollY = Math.Min(h, scrollY); mScrollY = scrollY > h ? h : scrollY; buttonBar.Alpha = 1f * mScrollY / h; mToolbar.SetBackgroundColor(new Android.Graphics.Color(((255 * mScrollY / h) << 24) | color)); parallax.TranslationY = mOffset - mScrollY; } lastScrollY = scrollY; }; buttonBar.Alpha = 0; mToolbar.SetBackgroundColor(new Android.Graphics.Color(0)); }
private void Init(Context context) { mMode = MODE_NORMAL; Width = DensityUtil.Dip2Px(context, DEFAULT_Width); Height = DensityUtil.Dip2Px(context, DEFAULT_Height); mTextSize = DensityUtil.Dip2Px(context, DEFAULT_TEXT_SIZE); mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_Width); mCenterRadius = DensityUtil.Dip2Px(context, DEFAULT_CENTER_RADIUS); mProgressCenterRadius = DensityUtil.Dip2Px(context, DEFAULT_PROGRESS_CENTER_RADIUS); mProgressColor = DEFAULT_PROGRESS_COLOR; mProgressBgColor = DEFAULT_PROGRESS_BGCOLOR; mElectricFanBgColor = DEFAULT_ELECTRIC_FAN_BGCOLOR; mElectricFanOutlineColor = DEFAULT_ELECTRIC_FAN_OUTLINE_COLOR; mLeafDrawable = context.GetDrawable(Resource.Drawable.ic_leaf); mLoadingDrawable = context.GetDrawable(Resource.Drawable.ic_loading); mElectricFanDrawable = context.GetDrawable(Resource.Drawable.ic_eletric_fan); Duration = ANIMATION_DURATION; SetInsets((int)Width, (int)Height); }
private void Init(Context context) { Width = DensityUtil.Dip2Px(context, DEFAULT_Width); Height = DensityUtil.Dip2Px(context, DEFAULT_Height); mStrokeWidth = DensityUtil.Dip2Px(context, DEFAULT_STROKE_Width); mStarRadius = DensityUtil.Dip2Px(context, DEFAULT_STAR_RADIUS); mSun_MoonRadius = DensityUtil.Dip2Px(context, DEFAULT_SUN_MOON_RADIUS); mInitSun_MoonCoordinateY = Height + mSun_MoonRadius + mStrokeWidth * 2.0f; mMaxSun_MoonRiseDistance = Height / 2.0f + mSun_MoonRadius; mSunRayStartCoordinateY = mInitSun_MoonCoordinateY - mMaxSun_MoonRiseDistance - mSun_MoonRadius - mStrokeWidth - DensityUtil.Dip2Px(context, DEFAULT_SUN_RAY_OFFSET); //sub the interval between the sun and the sun ray - sub the with the sun circle - sub the radius - the center //add strokeWidth * 2.0f because the stroke cap is Paint.Cap.ROUND mSunRayEndCoordinateY = mSunRayStartCoordinateY - DensityUtil.Dip2Px(context, DEFAULT_SUN_RAY_LENGTH) + mStrokeWidth; mSunCoordinateY = mInitSun_MoonCoordinateY; mMoonCoordinateY = mInitSun_MoonCoordinateY; mCurrentColor = DEFAULT_COLOR; Duration = ANIMATION_DURATION; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_fly_refresh); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); toolbar.NavigationClick += (sender, e) => { Finish(); }; /************************************************************ * 关键代码-开始 ************************************************************/ mFlyView = FindViewById <FlyView>(Resource.Id.flyview); mScenceView = FindViewById <MountanScenceView>(Resource.Id.mountan); mFlyRefreshHeader = FindViewById <FlyRefreshHeader>(Resource.Id.flyrefresh); mFlyRefreshHeader.SetUp(mScenceView, mFlyView); //绑定场景和纸飞机 mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; mRefreshLayout.SetReboundInterpolator(new ElasticOutInterpolator()); //设置回弹插值器,会带有弹簧震动效果 mRefreshLayout.SetReboundDuration(800); //设置回弹动画时长 mRefreshLayout.SetOnRefreshListener(new CustomOnRefreshListener(this)); //设置 让 AppBarLayout 和 RefreshLayout 的滚动同步 并不保持 toolbar 位置不变 appBar = FindViewById <AppBarLayout>(Resource.Id.app_bar); mRefreshLayout.SetOnMultiPurposeListener(new CustomOnMultiPurposeListener(this)); /************************************************************ * 关键代码-结束 ************************************************************/ mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; if (isFirstEnter) { isFirstEnter = false; mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果 } /** * 初始化列表数据 */ initDataSet(); mAdapter = new ItemAdapter(this); mLayoutManager = new LinearLayoutManager(this); mListView = FindViewById <RecyclerView>(Resource.Id.recyclerView); mListView.SetLayoutManager(mLayoutManager); mListView.SetAdapter(mAdapter); mListView.SetItemAnimator(new SampleItemAnimator()); mToolbarLayout = FindViewById <CollapsingToolbarLayout>(Resource.Id.toolbar_layout); mActionButton = FindViewById <FloatingActionButton>(Resource.Id.fab); //设置点击 ActionButton 时候触发自动刷新 并改变主题颜色 mActionButton.Click += (sender, e) => { updateTheme(); mRefreshLayout.AutoRefresh(); }; // 监听 AppBarLayout 的关闭和开启 给 FlyView(纸飞机) 和 ActionButton 设置关闭隐藏动画 appBar.OffsetChanged += (sender, e) => { var appBarLayout = e.AppBarLayout; var verticalOffset = e.VerticalOffset; int scrollRange = appBarLayout.TotalScrollRange; float fraction = 1f * (scrollRange + verticalOffset) / scrollRange; if (fraction < 0.1 && misAppbarExpand) { misAppbarExpand = false; mActionButton.Animate().ScaleX(0).ScaleY(0); mFlyView.Animate().ScaleX(0).ScaleY(0); ValueAnimator animator = ValueAnimator.OfInt(mListView.PaddingTop, 0); animator.SetDuration(300); animator.Update += (senderr, ee) => { mListView.SetPadding(0, (int)ee.Animation.AnimatedValue, 0, 0); }; animator.Start(); } if (fraction > 0.8 && !misAppbarExpand) { misAppbarExpand = true; mActionButton.Animate().ScaleX(1).ScaleY(1); mFlyView.Animate().ScaleX(1).ScaleY(1); ValueAnimator animator = ValueAnimator.OfInt(mListView.PaddingTop, DensityUtil.Dp2px(25)); animator.SetDuration(300); animator.Update += (senderr, ee) => { mListView.SetPadding(0, (int)ee.Animation.AnimatedValue, 0, 0); }; animator.Start(); } }; //状态栏透明和间距处理 StatusBarUtil.immersive(this); StatusBarUtil.setPaddingSmart(this, toolbar); // StatusBarUtil.setPaddingSmart(this, findViewById(R.id.profile)); // StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurview)); }
public override void OnPageCommitVisible(WebView view, string url) { _activity.mRefreshLayout.FinishRefresh(); view.LoadUrl(Java.Lang.String.Format(Locale.China, "javascript:document.body.style.paddingTop='%fpx'; void 0", DensityUtil.Px2dp(_activity.webView.PaddingTop))); }
private void InitParams(Context context) { Width = DensityUtil.Dip2Px(context, DEFAULT_SIZE); Height = DensityUtil.Dip2Px(context, DEFAULT_SIZE); Duration = ANIMATION_DURATION; }
public int Dp2Px(int value) { return(DensityUtil.Dp2px(Android.App.Application.Context, value)); }