安卓中的 Medium 字重

關於安卓字體,ui的設計稿上是不是經常出現,這樣的 字重 Medium,
但是textview 中找了半天也沒有啊,於是打開百度,面向百度編程。

找了一些字體,直接貼代碼吧,xml文件,直接複製過去,就能有明顯的對比。

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_marginStart="20dp"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />

    <TextView
        android:id="@+id/tv1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-condensed"
        android:text="Hello World!" />

    <TextView
        android:id="@+id/tv2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-black"
        android:text="Hello World!" />


    <TextView
        android:id="@+id/tv3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-medium"
        android:text="Hello World!" />

    <TextView
        android:id="@+id/tv4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-condensed-medium"
        android:text="Hello World!" />


    <TextView
        android:id="@+id/tv5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="cursive"
        android:text="Hello World!" />


    <TextView
        android:id="@+id/tv6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="monospace"
        android:text="Hello World!" />


    <TextView
        android:id="@+id/tv7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />


    <TextView
        android:textStyle="bold"
        android:id="@+id/tv8"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />





</LinearLayout>

經過對比較爲貼近 Medium 這種字體
android:fontFamily=“sans-serif-condensed-medium”

如果還覺得不行,打開AS(本人目前使用AS3.5),找到一個有textview相關的xml文件,然後

在這裏插入圖片描述
看到下面這個紅框沒,找你想要的字體,有時間可以挨個去試。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章