差不多這個效果:
全部**:
package com.example.jadynai.loadinglovely.flicker;
import android.animation.animator;
import android.animation.animatorlisteneradapter;
import android.animation.valueanimator;
import android.content.context;
import android.graphics.canvas;
import android.graphics.color;
import android.graphics.lineargradient;
import android.graphics.matrix;
import android.graphics.shader;
import android.support.annotation.intrange;
import android.util.attributeset;
import android.util.log;
import android.view.view;
import android.view.animation.linearinterpolator;
/** * @version:
* @filedescription:
* @author:馮人唐
* @since:2018/5/2
* @changelist:
*/ private static final string tag = "textflickerview";
//閃光的寬度
public static final int shadow_w = 50;
private matrix mshadowmatrix;
private lineargradient mlineargradient;
private valueanimator mvalueanimator;
private int mrepeatcount = 50;
public textflickerview(context context)
public textflickerview(context context, attributeset attrs)
public textflickerview(context context, attributeset attrs, int defstyleattr)
@override
protected void onsizechanged(int w, int h, int oldw, int oldh)
@override
protected void ondraw(canvas canvas)
}private void tryinitengine(int w) ,
null, shader.tilemode.clamp);
//畫筆設定shader
getpaint().setshader(mlineargradient);
//使用屬性動畫作為引擎,數值從-shadow變化到textview本身的寬度。間隔時間未1500ms
mvalueanimator = valueanimator.offloat(-shadow_w, w).setduration(1500);
mvalueanimator.setinterpolator(new linearinterpolator());
mvalueanimator.addupdatelistener(new valueanimator.animatorupdatelistener()
});mvalueanimator.addlistener(new animatorlisteneradapter()
@override
public void onanimationend(animator animation)
});mvalueanimator.setrepeatcount(mrepeatcount);}}
}public void setduration(@intrange(from = 1, to = 15) int second)
}public void start()
}}, 100);}}
@override
public void onwindowfocuschanged(boolean haswindowfocus)
@override
protected void onvisibilitychanged(view changedview, int visibility)
@override
protected void ondetachedfromwindow()
private void release()
mshadowmatrix = null;
mlineargradient = null;}}
這是原專案位址 仿京東放大鏡效果
案例分析 1.整個案例可以分為三個功能模組 2.滑鼠經過小盒子,黃色的遮擋層和大盒子顯示,離開時2個盒子隱藏功能 3.黃色的遮擋層跟隨滑鼠移動功能 4.移動黃色遮擋層,大跟隨移動功能。效果 html部分 1 doctype html 2 html lang en 3 head 4 meta char...
iOS引導頁 啟動頁
前言 這裡使用launchscreen storyboard檔案建立啟 和引導頁。首次開啟專案或者更新後第一次開啟時展示引導頁,儲存有使用者資訊時進入首頁,否則進入登入註冊頁面。正文1.動態啟 將launchscreen.storyboard檔案上放入乙個。並新增約束,鋪滿整個頁面。為launchs...
iOS啟動頁設定
步驟 1 assets.xcassets 新增 launch image 2 如圖,右側的勾選可以讓你選擇是否要對ipad,橫屏,豎屏,以及低版本的ios系統做支援.這邊我選了ios8.0,ios7.0,ios6。然後將規定尺寸的,從你的檔案中拖動到固定位置,如尺寸不對,會有警告提示。3.單擊你的整...