荔枝FM 字体文件 IconFontTextView
使用效果
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_margin="10dp"android:orientation="horizontal"><com.bqt.lizhi.demo.IconFontTextViewandroid:layout_width="40dp"android:layout_height="40dp"android:background="@android:color/holo_blue_bright"android:gravity="center"android:text="@string/ic_live_talk_jockey_microphone_off"android:textColor="#f00"android:textSize="17sp"/><com.bqt.lizhi.demo.IconFontTextViewandroid:layout_width="40dp"android:layout_height="40dp"android:layout_marginLeft="10dp"android:gravity="center"android:text="@string/ic_record_audition"android:textColor="#0f0"android:textSize="17sp"app:if_fillColor="#3f00"/><com.bqt.lizhi.demo.IconFontTextViewandroid:layout_width="40dp"android:layout_height="40dp"android:layout_marginLeft="10dp"android:background="@android:color/holo_blue_bright"android:gravity="center"android:text="@string/ic_live_ent_mode"android:textColor="#00f"android:textSize="17sp"app:if_fillColor="#3f00"/><com.bqt.lizhi.demo.IconFontTextViewandroid:layout_width="40dp"android:layout_height="40dp"android:layout_marginLeft="10dp"android:gravity="center"android:text="@string/ic_live_talk_loudspeaker"android:textColor="#000"android:textSize="17sp"app:if_strokeColor="#0f0"app:if_strokeWidth="2dp"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="horizontal">
<com.bqt.lizhi.demo.IconFontTextView
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@android:color/holo_blue_bright"
android:gravity="center"
android:text="@string/ic_live_talk_jockey_microphone_off"
android:textColor="#f00"
android:textSize="17sp"/>
<com.bqt.lizhi.demo.IconFontTextView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="@string/ic_record_audition"
android:textColor="#0f0"
android:textSize="17sp"
app:if_fillColor="#3f00"/>
<com.bqt.lizhi.demo.IconFontTextView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:background="@android:color/holo_blue_bright"
android:gravity="center"
android:text="@string/ic_live_ent_mode"
android:textColor="#00f"
android:textSize="17sp"
app:if_fillColor="#3f00"/>
<com.bqt.lizhi.demo.IconFontTextView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="@string/ic_live_talk_loudspeaker"
android:textColor="#000"
android:textSize="17sp"
app:if_strokeColor="#0f0"
app:if_strokeWidth="2dp"/>
</LinearLayout>
控件 IconFontTextView
public class IconFontTextView extends android.support.v7.widget.AppCompatTextView {private Paint paint;private int strokeWidth;private int strokeColor;private int fillColor;private boolean enablePressEffect = true; // 按下半透明效果public IconFontTextView(Context context) {this(context, null);}public IconFontTextView(Context context, AttributeSet attrs) {this(context, attrs, 0);}public IconFontTextView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);this.setTypeface(IconFontUtil.getIconfont(context));TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconFontTextView, defStyleAttr, 0);strokeColor = a.getColor(R.styleable.IconFontTextView_if_strokeColor, 0);strokeWidth = a.getDimensionPixelSize(R.styleable.IconFontTextView_if_strokeWidth, 0);fillColor = a.getColor(R.styleable.IconFontTextView_if_fillColor, 0);enablePressEffect = a.getBoolean(R.styleable.IconFontTextView_if_enablePressEffect, true);a.recycle();paint = new Paint();paint.setAntiAlias(true);}public void setStrokeColor(@ColorInt int strokeColor) {this.strokeColor = strokeColor;invalidate();}@Overridepublic void setPressed(boolean pressed) {super.setPressed(pressed);if (!isEnabled()) {return;}if (enablePressEffect) {if (pressed) {setAlpha(0.5F);} else {setAlpha(1);}}}@Overridepublic void setEnabled(boolean enabled) {super.setEnabled(enabled);if (enabled) {setAlpha(1);} else {setAlpha(0.2F);}}@Overrideprotected void onDraw(Canvas canvas) {int center = getWidth() / 2;if (strokeColor != 0) {if (strokeWidth != 0) {this.paint.setStyle(Paint.Style.STROKE);this.paint.setStrokeWidth(strokeWidth);}this.paint.setColor(strokeColor);if (strokeWidth != -1) {canvas.drawCircle(center, center, getWidth() / 2 - strokeWidth / 2, this.paint);} else {canvas.drawCircle(center, center, getWidth() / 2, this.paint);}}if (fillColor != 0) {this.paint.setStyle(Paint.Style.FILL);this.paint.setColor(fillColor);canvas.drawCircle(center, center, getWidth() / 2, this.paint);}super.onDraw(canvas);}
}
x
public class IconFontTextView extends android.support.v7.widget.AppCompatTextView {
private Paint paint;
private int strokeWidth;
private int strokeColor;
private int fillColor;
private boolean enablePressEffect = true; // 按下半透明效果
public IconFontTextView(Context context) {
this(context, null);
}
public IconFontTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public IconFontTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.setTypeface(IconFontUtil.getIconfont(context));
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconFontTextView, defStyleAttr, 0);
strokeColor = a.getColor(R.styleable.IconFontTextView_if_strokeColor, 0);
strokeWidth = a.getDimensionPixelSize(R.styleable.IconFontTextView_if_strokeWidth, 0);
fillColor = a.getColor(R.styleable.IconFontTextView_if_fillColor, 0);
enablePressEffect = a.getBoolean(R.styleable.IconFontTextView_if_enablePressEffect, true);
a.recycle();
paint = new Paint();
paint.setAntiAlias(true);
}
public void setStrokeColor(@ColorInt int strokeColor) {
this.strokeColor = strokeColor;
invalidate();
}
@Override
public void setPressed(boolean pressed) {
super.setPressed(pressed);
if (!isEnabled()) {
return;
}
if (enablePressEffect) {
if (pressed) {
setAlpha(0.5F);
} else {
setAlpha(1);
}
}
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
if (enabled) {
setAlpha(1);
} else {
setAlpha(0.2F);
}
}
@Override
protected void onDraw(Canvas canvas) {
int center = getWidth() / 2;
if (strokeColor != 0) {
if (strokeWidth != 0) {
this.paint.setStyle(Paint.Style.STROKE);
this.paint.setStrokeWidth(strokeWidth);
}
this.paint.setColor(strokeColor);
if (strokeWidth != -1) {
canvas.drawCircle(center, center, getWidth() / 2 - strokeWidth / 2, this.paint);
} else {
canvas.drawCircle(center, center, getWidth() / 2, this.paint);
}
}
if (fillColor != 0) {
this.paint.setStyle(Paint.Style.FILL);
this.paint.setColor(fillColor);
canvas.drawCircle(center, center, getWidth() / 2, this.paint);
}
super.onDraw(canvas);
}
}
获取字体 IconFontUtil
public class IconFontUtil {private static Typeface mIconfont;public static Typeface getIconfont(Context context) {if (mIconfont == null) {mIconfont = Typeface.createFromAsset(context.getAssets(), "iconfont/lizhifm.ttf");}return mIconfont;}
}
x
public class IconFontUtil {
private static Typeface mIconfont;
public static Typeface getIconfont(Context context) {
if (mIconfont == null) {
mIconfont = Typeface.createFromAsset(context.getAssets(), "iconfont/lizhifm.ttf");
}
return mIconfont;
}
}
自定义属性 attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources><declare-styleable name="IconFontTextView"><attr name="if_strokeWidth" format="dimension"/><attr name="if_strokeColor" format="color"/><attr name="if_fillColor" format="color"/><attr name="if_enablePressEffect" format="boolean"/></declare-styleable>
</resources>
x
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="IconFontTextView">
<attr name="if_strokeWidth" format="dimension"/>
<attr name="if_strokeColor" format="color"/>
<attr name="if_fillColor" format="color"/>
<attr name="if_enablePressEffect" format="boolean"/>
</declare-styleable>
</resources>
字体效果
附件列表
荔枝FM 字体文件 IconFontTextView相关推荐
- [c#]喜马拉雅、蜻蜓、荔枝FM音频批量下载器V1.3 by Levme开发手记
0.前言 好久没在CSDN上写东西了,看了之前开发的下载器由于三个网站代码更新已经不能用了,应要求,重分析了三个网站播放机制,写了1.3版本的下载器,在我的资源里有下载. 贴个地址:https://d ...
- 面试06,[长亮科技]()(offer)、[荔枝]()FM(在确定部门和薪资)、[涂鸦智能]()(第一轮电话面半小时,待后续)、华资软件(HR面)、[广州速游]()(已挂)。至于公司怎么样不加以言论。
作者:Carson-Zhao 链接:https://ac.nowcoder.com/discuss/522002?type=2&order=0&pos=16&page=1&am ...
- fm计算机,荔枝FM电脑版
荔枝FM电脑版官方版是一款因为热爱而生的音乐产品,专注于发现和分享优质音乐内容,其创新领先的录音功能开启"人人都是主播"的时代.独具匠心的设计.多样化的内容.个性化的体验,用心为用 ...
- 直播用什么声音测试软件,荔枝FM直播助手测试方法,请看图文说明
荔枝FM直播助手,这款专门为主播们打造的辅助工具,相信很多资深的直播玩家都对它非常熟悉.可是,对于很多新手主播来说,在利用它时,却发现自己无法正确驾驭它.那么,荔枝FM直播助手怎么用才能为自己的听众们 ...
- 荔枝FM架构师刘耀华:异地多活IDC机房架构
声明:本文首发于CSDN,禁止未经许可的任何形式转载,可咨询文末的责编. 多机房架构存在的原因 单机房一旦死机,断电.维护根本无法挽回整个数据,想离线读取等都不行.当一个机房不可用,所有的业务就都不可 ...
- 荔枝fm电脑版 v1.5.2 官方版
荔枝fm电脑版 v1.5.2 官方版 软件大小:9.4MB 软件语言:简体中文 软件类别:影音其他 软件授权:官方版 应用平台:/Win8/Win7/WinXP 是一款基于模拟器的音乐电台.荔枝fm电 ...
- 荔枝FM:异地多活IDC机房架构
http://geek.csdn.net/news/detail/53231 多机房架构存在的原因 单机房一旦死机,断电.维护根本无法挽回整个数据,想离线读取等都不行.当一个机房不可用,所有的业务就都 ...
- 通过上传ttf或者otf字体文件生成对应字体的图片
由于项目需求,需要通过上传的字体文件来生成对应的图片以方便用户快速查看字体效果,经查阅信息后完成此需求,记录下此以供日后学习巩固.根据思路,首先是获取到字体文件的url,然后根据url获取到字体文件, ...
- apache字体文件跨域_apache如何解决跨域资源访问
很多时候,大中型网站为了静态资源分布式部署,加快访问速度,减轻主站压力,会把静态资源(例如字体文件.图片等)放在独立服务器或者CDN上,并且使用独立的资源域名(例如res.test.com) 但是在实 ...
最新文章
- 判断两个数组内容是否相同
- 测试core :: demangled_name
- DSPack的Demo中,那个VMR目录是什么意思?
- linux 多个会话同时执行命令后history记录不全的解决方案
- anaconda来创建python环境
- RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'target'
- 海龟交易法则10_通用积木
- 安装了IE8.0之后网页按钮变小的恢复
- SVN 代码与文件管理小记
- docker tensorflow_用Docker容器方式安装TensorFlow
- 转并学习: 将rar文件转换为zip格式
- [R]_R里如何将多个Excel文件合并为一个Excel文件多个Sheet
- ZBrush如何结合数位板雕刻模型
- winrar捆绑软件
- 移动硬盘格式化了的数据找回方法
- 【推荐】超级好用的打印插件Lodop使用笔记 动态赋值 打印模板解决方案
- 岁月的感知,生命的守望
- 如何监控Redis性能指标
- python课程设计----简单爬虫
- 鸿蒙系统浏览器内核,四大浏览器横评出炉:Chromium 内核版 Edge 四项夺冠,优于原生 Chrome...
热门文章
- BZOJ 2947 Poi2000 促销 set
- Java总结篇系列:Java多线程(二)
- android主流开源自动化框架(monkeyrunner,robotium,uiautomator
- 转载 - 使用HTML5、CSS3和jQuery增强网站用户体验
- 我在51cto微职位学软考——宝妈一次性通过高项的学习经历
- Redis 4.0.X版本reshard出现错误的解决办法
- NSURLConnection实现文件上传和AFNetworking实现文件上传
- Scrumban-拉动企业渐进式变革的利器
- 最初的感动:各种应用和代码在BCH这里不断复活
- iOS swift2.3 迁移到3.0 遇到的一些问题