728x90
1. res -> font 파일 생성하기
2. 원하는 폰트를 디렉토리 안에 넣는다!
3. android:fontFamily 옵션을 통해서 적용 가능하다
폰트 일괄 적용하기!
1. -custom_fontfamily.xml 파일 생성
<?xml version="1.0" encoding="utf-8"?>
<font-family
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--regular-->
<font
android:font="@font/ganwon_tuentuen"
android:fontStyle="normal"
android:fontWeight="400"
app:font="@font/ganwon_tuentuen"
app:fontStyle="normal"
app:fontWeight="500" />
<!--bold-->
<font
android:font="@font/ganwon_tuentuen_bold"
android:fontStyle="normal"
android:fontWeight="700"
app:font="@font/ganwon_tuentuen_bold"
app:fontStyle="normal"
app:fontWeight="1000" />
</font-family>
2. res/values/themes.xml 안에 뷰들에 대한 글꼴들을 바꿔준다
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Week6_7_Game" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="windowNoTitle">true </item>
<item name="windowActionBar">false</item>
<!--custom font-family 적용-->
<item name="android:textViewStyle">@style/customTextViewFontStyle</item>
<item name="android:buttonStyle">@style/customButtonFontStyle</item>
<item name="android:editTextStyle">@style/customEditTextFontStyle</item>
<item name="android:radioButtonStyle">@style/customRadioButtonFontStyle</item>
<item name="android:checkboxStyle">@style/customCheckboxFontStyle</item>
</style>
<!-- Custom font 적용 -->
<style name="customTextViewFontStyle" parent="@android:style/Widget.DeviceDefault.TextView">
<item name="android:fontFamily">@font/custom_fontfamily</item>
</style>
<style name="customButtonFontStyle" parent="@android:style/Widget.DeviceDefault.Button.Borderless">
<item name="android:fontFamily">@font/custom_fontfamily</item>
</style>
<style name="customEditTextFontStyle" parent="@android:style/Widget.DeviceDefault.EditText">
<item name="android:fontFamily">@font/custom_fontfamily</item>
</style>
<style name="customRadioButtonFontStyle" parent="@android:style/Widget.DeviceDefault.CompoundButton.RadioButton">
<item name="android:fontFamily">@font/custom_fontfamily</item>
</style>
<style name="customCheckboxFontStyle" parent="@android:style/Widget.DeviceDefault.CompoundButton.CheckBox">
<item name="android:fontFamily">@font/custom_fontfamily</item>
</style>
</resources>
3. 이후 layout.xml페이지에서 textsytle만 주면 성공!
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/login_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:background="@color/colorWhite"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textStyle="bold"
android:text="네이버 나눔바른펜 Bold 적용"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textStyle="normal"
android:text="네이버 나눔바른펜 Reqular 적용"/>
</LinearLayout>
https://noonnu.cc/ 여기서 무료 폰트 다운 가능하다
https://www.sandollcloud.com/openfreefonts.html?gb=free
728x90
'기타 > Android' 카테고리의 다른 글
[Android] Progressbar 커스텀하기 (색상변경, 테두리) (0) | 2022.02.19 |
---|---|
[Android] 원형 버튼 만들기 (0) | 2022.02.19 |
[Android Studio] xml android:background 색상 안바뀔때 (0) | 2022.02.04 |
[AndroidStudio] Unable to decode stream: java.io.FileNotFoundException오류 (0) | 2021.12.01 |
[안드로이드 스튜디오] style.xml 파일 없음 (0) | 2021.12.01 |