1

I have been researching how I might user Roboto in my android app. I stumbled on a seemingly promising git project dedicated specifically to what I needed. But when I download the project, it refuses to work. Some of the things I try as troubleshooting

  • properties > android > Android 4.4.2
  • change from minSdkVersion 3 to 11: android:minSdkVersion="11"

I am still getting

error: No resource identifier found for attribute 'typeface' in package 
 'com.devspark.robototextview.sample'

in the single layout file: activity_main.xml

The project is at https://github.com/johnkil/Android-RobotoTextView

Does anyone know how I might get it to work or have some advise at using Roboto with such equivalent simplicity?

Update

I am using eclipse on mac osx mavericks. I just checked and see that the src folder is empty and that the MainActivity.java file is literally under the path of folders consisting: java>com>devspark>robototextview>sample. So my first guess is that eclipse does not know how to import the project. Does anyone know how I might fix that, if indeed it's the problem. By the way, all my projects are on git and I have been using samples and libraries from git for a while now. So the problem is likely this particular project.

learner
  • 11,490
  • 26
  • 97
  • 169
  • Can you post some code you're trying out ? – Ye Lin Aung Jun 13 '14 at 04:51
  • @YeLinAung I am not sure what you mean. The git I mention is the sample. The link again is https://github.com/johnkil/Android-RobotoTextView. Otherwise I am not sure of the objective of the question. – learner Jun 13 '14 at 04:56

1 Answers1

0

Sample Layout :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">

    <TextView
            android:id="@+id/custom_font"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="This is the roboto font."/>

</LinearLayout>

Place the font file in assets/fonts (Create the fonts inside the assets folder)

Inside the activity :

TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
txt.setTypeface(font);
Shivam Verma
  • 7,973
  • 3
  • 26
  • 34
  • yeah, I am hoping to avoid calling Typeface inside the source. Do you know a simple way to do it in xml? – learner Jun 13 '14 at 04:57
  • You can but you'll need to create a custom class which extends textView and override methods where you set the style. In case you dont have a LOT of textViews, this method would be easier. – Shivam Verma Jun 13 '14 at 05:02
  • Check this answer : http://stackoverflow.com/questions/14631326/use-roboto-font-in-app-with-minimum-api-level-14/14633032#14633032 Also, read the comments for a better explanation. – Shivam Verma Jun 13 '14 at 05:06