7、应用字体。首先建一个字体“映射”类,反正官方不太推荐用枚举方式,暂且就用注解吧~~ 打开刚才解压包里面的demo.html,对应来创建字体映射。
import android.support.annotation.StringDef; /** * @author yuyh. * @date 2016/11/10. */ @StringDef({ MDFonts.HOME, MDFonts.NEWSPAPER, MDFonts.MUSIC, MDFonts.PLAY }) public @interface MDFonts { String HOME = "\ue902"; String NEWSPAPER = "\ue904"; String MUSIC = "\ue911"; String PLAY = "\ue912"; }
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
import android.content.Context; import android.graphics.Typeface; import android.widget.TextView; /** * @author yuyh. * @date 2016/11/10. */ public class MDFontsUtils { public static Typeface OCTICONS; /** * Get octicons typeface * * @param context * @return octicons typeface */ public static Typeface getOcticons(final Context context) { if (OCTICONS == null) OCTICONS = getTypeface(context, "fonts/icomoon.ttf"); return OCTICONS; } /** * Set octicons typeface on given text view(s) * * @param textViews */ public static void setOcticons(final TextView... textViews) { if (textViews == null || textViews.length == 0) return; Typeface typeface = getOcticons(textViews[0].getContext()); for (TextView textView : textViews) textView.setTypeface(typeface); } /** * Get typeface with name * * @param context * @param name * @return typeface */ public static Typeface getTypeface(final Context context, final String name) { return Typeface.createFromAsset(context.getAssets(), name); } }
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
9、图标对应是用TextView表示,而不是ImageView。如下:
<TextView android:id="@+id/tvMusic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:textSize="16dp" /> <TextView android:id="@+id/tvHome" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp" android:textSize="16dp" />
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
在Java中应用字体。如下:
tvMusic = (TextView) findViewById(R.id.tvMusic); tvMusic.setText(MDFonts.MUSIC); tvHome = (TextView) findViewById(R.id.tvHome); tvHome.setText(MDFonts.HOME); // 应用字体 MDFontsUtils.setOcticons(tvMusic, tvHome);
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
run起来,大功告成!
10、你会发现,run起来图标颜色全是Android默认的灰色,那么怎么更改图标颜色呢?刚才说了,图标字体用的是TextView,实际上他跟中文英文字体没什么两样,他本质上还是文字。所以,TextView怎么设置字体大小、字体颜色,这里就对应怎么设置。如下:
tvHome.setTextColor(Color.RED); tvHome.setTextSize(50);
-
1
-
2
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
最后
我坚信,坚持学习,每天进步一点,滴水穿石,我们离成功都很近!
以下是总结出来的字节经典面试题目,包含:计算机网络,Kotlin,数据结构与算法,Framework源码,微信小程序,NDK音视频开发,计算机网络等。
字节高级Android经典面试题和答案
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
以下是总结出来的字节经典面试题目,包含:计算机网络,Kotlin,数据结构与算法,Framework源码,微信小程序,NDK音视频开发,计算机网络等。
字节高级Android经典面试题和答案
[外链图片转存中…(img-7bfzmr5e-1712350945220)]
[外链图片转存中…(img-UjpfzCni-1712350945221)]
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!