I am trying to add a icon
to my textview
. My java code for the corresponding fragment is:
public class BlankFragment extends Fragment {
public BlankFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),
"fonts/weathericons-regular-webfont.ttf");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
....
TextView name_sunrise = rootView.findViewById(R.id.tv_sunr);
//name_sunrise.setText(); Here I want to put an icon from tf
My xml for tv_sunr is defined as:
<TextView
android:id="@+id/tv_sunr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/tv_sunrt"
android:layout_alignBottom="@+id/tv_sunrt"
android:layout_toEndOf="@+id/iv_image"
android:paddingLeft="10sp"
android:text="@string/sunrise"
android:textSize="20sp"></TextView>
And the text I am trying to replace is android:text="@string/sunrise"
defined in strings
as:
<string name="sunrise">SunRise</string>
The question is twofold:
- How to add the
ttf
to the textview - How to find the actual item in the ttf file I am looking to use (e.g. in this case, how to find the font for sunrise)
I am using this ttf from github.
I am following this tutorial, but stuck here.
UPDATE
Hi, from the weather icon, I have found that the icon I want to use is named as wi-sunset
. The problem is how I will use that icon. Kindly help.