AndroidBanner广告条-创新互联
package com.example.ex_templete;
创新互联建站专注于网站建设,为客户提供网站建设、成都网站设计、网页设计开发服务,多年建网站服务经验,各类网站都可以开发,品牌网站设计,公司官网,公司展示网站,网站设计,建网站费用,建网站多少钱,价格优惠,收费合理。import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
public class ViewPagerIndicator extends View {
private Paint paint;
private Paint forePaint;
private float foreOffset;
private static final int RADIUS = 10;
private static int PIVOT_X = 30;
private static final int PIVOT_Y = 30;
private static final int LEN = 3 * RADIUS;
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = (7 - 1) * LEN + 2 * RADIUS;
int screenWidth = getScreenWidth();
PIVOT_X = (screenWidth - width) / 2;
for (int i = 0; i < 7; i++) {
canvas.drawCircle(PIVOT_X + i * 3 * RADIUS, PIVOT_Y, RADIUS, paint);
}
canvas.drawCircle(PIVOT_X + foreOffset, PIVOT_Y, RADIUS, forePaint);
}
// 得到屏幕的Width
private int getScreenWidth() {
WindowManager windowMgr = (WindowManager)
getContext().getSystemService
(Context.WINDOW_SERVICE);
Display display = windowMgr.getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics();
display.getMetrics(outMetrics);
return outMetrics.widthPixels;
}
public void updateOffset(int position, float positionOffset)
{
foreOffset = position % 7 * LEN
+ positionOffset * LEN;
invalidate();
}
public ViewPagerIndicator(Context context, AttributeSet attrs) {
super(context, attrs);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.RED);
paint.setStyle(Style.STROKE);// 绌哄績
paint.setStrokeWidth(1);// 杈圭殑鍘氬害
forePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
forePaint.setColor(Color.BLUE);
}
}
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页题目:AndroidBanner广告条-创新互联
文章出自:http://pwwzsj.com/article/iopss.html