Android 自总结的一些小细节

2019-01-12  本文已影响8人  yzzCool

前言

TextView是安卓开发人员接触最早的控件,Android Studio新建一个默认工程,进入之后展现在我们面前的就是Hello World,呈现这个文字的控件就是TextView。本文只是说一说一些应用。

相关的使用

1.行间距和字间距控制

说到这两个东西接触的还真没有这么多,但是文字距离的太近就是不好看。

行间距:行间距用android:lineSpacingExtra=“”或者setLineSpacing(float add, float mult)
字间距:android:letterSpacing=“”或者setLetterSpacing(float letterSpacing)

1.1 行间距,直接上代码:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="标识号会被烧入终端里,并且不能被修改。可用来对移动式设备进行身份识别和跟踪。由于ESN号段是有限的资源,基本上耗尽,可能还有少量回收利用的号段,所以制定了56bits的MEID号段,用来取代32bits的ESN号段。" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="5dp"
            android:background="@color/colorAccent" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:lineSpacingExtra="1dp"
            android:text="标识号会被烧入终端里,并且不能被修改。可用来对移动式设备进行身份识别和跟踪。由于ESN号段是有限的资源,基本上耗尽,可能还有少量回收利用的号段,所以制定了56bits的MEID号段,用来取代32bits的ESN号段。" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="5dp"
            android:background="@color/colorAccent" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:lineSpacingExtra="5dp"
            android:text="标识号会被烧入终端里,并且不能被修改。可用来对移动式设备进行身份识别和跟踪。由于ESN号段是有限的资源,基本上耗尽,可能还有少量回收利用的号段,所以制定了56bits的MEID号段,用来取代32bits的ESN号段。" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="5dp"
            android:background="@color/colorAccent" />

    </LinearLayout>

得到的效果图如下:


行间距

很明显上面3段是不同的。

1.2 字间距,直接上代码:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="标识号会被烧入终端里,并且不能被修改,默认" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:letterSpacing="-0.1"
            android:text="标识号会被烧入终端里,并且不能被修改,-0.1" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:letterSpacing="0.0"
            android:text="标识号会被烧入终端里,并且不能被修改,0.0" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:letterSpacing="0.1"
            android:text="标识号会被烧入终端里,并且不能被修改,0.1" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:letterSpacing="0.2"
            android:text="标识号会被烧入终端里,并且不能被修改,0.2" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:letterSpacing="0.3"
            android:text="标识号会被烧入终端里,并且不能被修改,0.3" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:letterSpacing="0.4"
            android:text="标识号会被烧入终端里,并且不能被修改,0.4" />
    </LinearLayout>

得到的效果如下图所示:


字间距

很明显写入不同的值,字体之间的间距,就是不同。注意:如果是负值,就有向里缩的感觉。

2.android color 透明度列表

这个就是自己的一个总结:总是要查找,不如自己记录一下。哈哈
下面的显示就是不透明度,记住不透明度!!!

0% 00
1% 03 11% 1C 21% 36 31% 4F 41% 69 51% 03 61% 1C 71% 36 81% 4F 91% 69
2% 05 12% 1F 22% 38 32% 52 42% 6B 52% 85 62% 9E 72% B8 82% D1 92% EB
3% 08 13% 21 23% 3B 33% 54 43% 6E 53% 87 63% A1 73% BA 83% D4 93% ED
4% 0A 14% 24 24% 3D 34% 57 44% 70 54% 8A 64% A3 74% BD 84% D6 94% F0
5% 0D 15% 26 25% 40 35% 59 45% 73 55% 8C 65% A6 75% BF 85% D9 95% F2
6% 0F 16% 29 26% 42 36% 5C 46% 75 56% 8F 66% A8 76% C2 86% DB 96% F5
7% 12 17% 2B 27% 45 37% 5E 47% 78 57% 91 67% AB 77% C4 87% DE 97% F7
8% 14 18% 2E 28% 47 38% 61 48% 7A 58% 94 68% AD 78% C7 88% E0 98% FA
9% 17 19% 30 29% 4A 39% 63 49% 7D 59% 96 69% B0 79% C9 89% E3 99% FC
10% 1A 20% 33 30% 4D 40% 66 50% 80 60% 99 70% B3 80% CC 90% E6 100% FF

3.android 历史版本和对应的API Level

name 版本代号 API Level
Android 9.0 Pie(馅饼) 28
Android 8.1 Oreo(奥利奥) 27
Android 8.0 Oreo(奥利奥) 26
Android 7.1 Nougat(牛轧糖) 25
Android 7.0 Nougat(牛轧糖) 24
Android 6.0 Marshmallow(棉花糖) 23
Android 5.1 Lollipop(棒棒糖) 22
Android 5.0 Lollipop(棒棒糖) 21
Android 4.4W KitKat(奇巧) 20
Android 4.4 KitKat(奇巧) 19
Android 4.3 Jelly Bean(果冻豆) 18
Android 4.2 Jelly Bean(果冻豆) 17
Android 4.1 Jelly Bean(果冻豆) 16
Android 4.0.3-4.0.4 Ice Cream Sandwich(冰淇淋三明治) 15
Android 4.0-4.0.2 Ice Cream Sandwich(冰淇淋三明治) 14
Android 3.2 Honeycomb(蜂巢) 13
Android 3.1 Honeycomb(蜂巢) 12
Android 3.0 Honeycomb(蜂巢) 11
Android 2.3.3-2.3.7 Gingerbread(姜饼) 10
Android 2.3 - 2.3.2 Gingerbread(姜饼) 9
Android 2.2 - 2.2.3 Froyo(冻酸奶) 8
Android 2.1 Éclair(闪电泡芙) 7
Android 2.0.1 Éclair(闪电泡芙) 6
Android 2.0 Éclair(闪电泡芙) 5
Android 1.6 Donut(甜甜圈) 4
Android 1.5 Cupcake(纸杯蛋糕) 3
Android 1.1 2
Android 1.0 1
上一篇 下一篇

猜你喜欢

热点阅读