Android O introduces a new feature, Fonts in XML, which lets you use fonts as resources. And I am creating the font
folder in resource file as it provided by Android developer, but the problem is that I am getting error that file name must end with .xml
while using the font
folder which is provided in Android O release.
Please check the below layout for it.
<TextView
android:id="@+id/txtMsgCount"
android:layout_width="wrap_content"
android:layout_height="16dp"
android:background="@drawable/msg_count"
android:gravity="center"
android:text="123"
android:fontFamily="@font/Montserrat_Regular" ////IT IS MY FONT STYLE
android:textColor="@android:color/white"
android:textSize="10sp" />
And please check the font
folder which I have created in res
with Montserrat_Regular.otf
file
I am getting the following error while using the above, which are as follows:
I have searched about it but did not get expected result, please check:
1. First Link
2. Second Link
3. Third Link
4. Forth Link
And the Font resource file
is not creating as I am clicking the Right-click the font folder and go to New > Font resource file
. But not getting the option of the Font resource file
, please check below:
Font resources are not fully supported by the Android Studio 2.3.3 build chain. Full support comes with Android Studio 3.0+ and its associated Android Plugin for Gradle version. At that point, you will be able to create a font/
resource directory that goes alongside layout/
, menu/
, etc.
IOW, hold off on this until you are ready to upgrade to Android Studio 3.0.