资源简介
仿微信6.1主界面,实现了底部Button的渐变和Fragment的渐变

代码片段和文件信息
package com.example.weixin;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Looper;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
public class ChangeColorText extends View {
int mColor = 0xFF45C01A;
String mText = “微信“;
int mTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP
12 getResources().getDisplayMetrics());
Canvas mCanvas;
Bitmap mBitmap;
Paint mPaint;
Bitmap mIconBitma;
float mAlpha;
Rect mIconRect;
Rect mTextBound;
Paint mTextPaint;
public ChangeColorText(Context context) {
super(context);
}
/**获取自定义属性的值*/
public ChangeColorText(Context context AttributeSet attrs) {
super(context attrs);
TypedArray a = context.obtainstyledAttributes(attrs
R.styleable.ChangeColorText);
// 获取各个自定义属性的值
int n = a.getIndexCount();
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
switch (attr) {
case R.styleable.ChangeColorText_icon:
BitmapDrawable drawable = (BitmapDrawable) a.getDrawable(attr);
mIconBitma = drawable.getBitmap();
break;
case R.styleable.ChangeColorText_color:
mColor = a.getColor(attr 0xFF45C01A);
break;
case R.styleable.ChangeColorText_text:
mText = a.getString(attr);
break;
case R.styleable.ChangeColorText_textSize:
mTextSize = (int) a.getDimension(attr TypedValue
.applyDimension(TypedValue.COMPLEX_UNIT_SP 12
getResources().getDisplayMetrics()));
break;
default:
break;
}
}
a.recycle(); // 这里一定要回收掉
// 初始化一些变量
mTextBound = new Rect();
mTextPaint = new Paint();
mTextPaint.setTextSize(mTextSize);
mTextPaint.setColor(0xff555555);
mTextPaint.getTextBounds(mText 0 mText.length() mTextBound);
}
@SuppressLint(“DrawAllocation“)
@Override
protected void onMeasure(int widthMeasureSpec int heightMeasureSpec) {
// 测量图标的宽高
super.onMeasure(widthMeasureSpec heightMeasureSpec);
int iconWidth = Math.min(getMeasuredWidth() - getPaddingLeft()
- getPaddingRight() getMeasuredHeight() - getPaddingTop()
- getPaddingBottom() - mTextBound.height());
int left = getMeasuredWidth() / 2 - iconWidth / 2;
int top = (getMeasuredHeight() - mTextBound.height()) / 2 - iconWidth
/ 2;
mIconRect = new Rect(left top left + iconWidth top + iconWidth);
}
@Override
protected void onDraw(Canvas canvas) {
// 绘制控件
canvas.drawBitmap(mIconBitma null mIconRectnull);
int alpha = (int) Math.ce
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 475 2015-04-14 16:44 testtest\.classpath
文件 844 2015-04-02 10:59 testtest\.project
文件 177 2015-04-02 10:59 testtest\.settings\org.eclipse.jdt.core.prefs
文件 861 2015-04-14 15:06 testtest\AndroidManifest.xm
文件 648327 2015-04-02 10:59 testtest\libs\android-support-v4.jar
文件 781 2015-04-02 10:59 testtest\proguard-project.txt
文件 563 2015-04-02 10:59 testtest\project.properties
文件 238 2015-04-14 15:06 testtest\res\drawable\tab_bg.xm
文件 7658 2015-04-14 15:06 testtest\res\drawable-hdpi\ic_launcher.png
文件 3777 2015-04-14 15:06 testtest\res\drawable-mdpi\ic_launcher.png
文件 2574 2015-04-14 15:06 testtest\res\drawable-mdpi\ic_menu_allfriends.png
文件 2786 2015-04-14 15:06 testtest\res\drawable-mdpi\ic_menu_emoticons.png
文件 1944 2015-04-14 15:06 testtest\res\drawable-mdpi\ic_menu_friendslist.png
文件 2130 2015-04-14 15:06 testtest\res\drawable-mdpi\ic_menu_start_conversation.png
文件 159 2015-04-14 15:06 testtest\res\drawable-xxhdpi\actionbar_add_icon.png
文件 1561 2015-04-14 15:06 testtest\res\drawable-xxhdpi\actionbar_search_icon.png
文件 1471 2015-04-14 15:29 testtest\res\drawable-xxhdpi\ic_ab_back_holo_dark_am.png
文件 1460 2015-04-14 15:29 testtest\res\drawable-xxhdpi\ic_ab_back_holo_light_am.png
文件 24777 2015-04-14 15:06 testtest\res\drawable-xxhdpi\ic_launcher.png
文件 1113 2015-04-14 15:06 testtest\res\drawable-xxhdpi\ic_menu1.png
文件 774 2015-04-14 15:06 testtest\res\drawable-xxhdpi\ic_menu2.png
文件 530 2015-04-14 15:06 testtest\res\drawable-xxhdpi\ic_menu3.png
文件 1377 2015-04-14 15:06 testtest\res\drawable-xxhdpi\ic_menu4.png
文件 1900 2015-04-14 15:30 testtest\res\drawable-xxhdpi\ic_menu_back.png
文件 2553 2015-04-14 15:06 testtest\res\layout\activity_main.xm
文件 983 2015-04-14 15:06 testtest\res\menu\main.xm
文件 465 2015-04-14 15:06 testtest\res\values\attr.xm
文件 220 2015-04-14 15:06 testtest\res\values\dimens.xm
文件 576 2015-04-14 15:06 testtest\res\values\strings.xm
文件 697 2015-04-14 15:06 testtest\res\values\st
............此处省略30个文件信息
- 上一篇:win8加载圆圈动画(含源码/demo)
- 下一篇:OpenGL画树的代码
相关资源
- 自已写的 自习室预约小程序微信125
- ectouch最新版JSAPI微信支付V3插
- ectouch 微信支付插件
- ecshop微信支付含手机版ectouch
- 微信小程序驾照考试题库demo完整
- 微信聊天机器人源码
- 新闻列表源码(微信小程序)
- 微信小程序——音乐播放器
- ipad微信协议机器人
- 豆瓣图书微信小程序
- 微信小程序-仿网易云音乐
- 官微刷票查票辅助(微信刷票查票辅
- 40款h5游戏+21款热门测试吸粉
- 微信小程序源码-合集5
- 使用delphi+intraweb进行微信开发1~4代码
- 微信群成员导出工具.zip
- 帝国CMS微信支付宝支付接口插件
- 日期控件---适用于微信、手机端
- 微信小程序开发视频+demo
- 企业微信JS-SDK调试工具
- axure 微信资源元件库
- 微信红包.xmind
- 基于微信小程序的校园二手商品交易
- 微信小游戏扑克24点源码
- 基于微信小程序外卖点餐系统 开题报
- 微信小程序 录音机源码
- 微信打飞机IOS版源代码
- 微信小程序源码-合集1.rar
- 微信小程序源码-合集3
- 微信支付预订单、查询、退款等接口
评论
共有 条评论