0

I am working on an application in which I have used custom fonts in layout.xml file from my utility class.

While running the app sometimes it displays proper text and sometimes it displays symbols only on Nexus 5 not on other phones. (Tested on Moto g2 & Samsung Galaxy S4). Please check image below.

Can you please help me out to solve this weird issue?

EDIT: I can not share whole xml file, please check below.

com.ul_offline_player.ui.custom_ui.views.RadioButtonRegularFont
    android:id="@+id/radio_survey_first"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="left"
    android:layout_margin="@dimen/settings_secondary_small_text_size"
    android:text=""
    android:textSize="@dimen/settings_primary_one_text_size"/>

And below is the utility class,

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.RadioButton;

public class RadioButtonRegularFont extends RadioButton{

 public RadioButtonRegularFont(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    public RadioButtonRegularFont(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public RadioButtonRegularFont(Context context) {
        super(context);
        init();
    }

    public void init() {
        Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/OpenSans-Regular.ttf");
        setTypeface(tf ,1);         
    }
}

enter image description here

Mitesh Shah
  • 192
  • 4
  • 16

0 Answers0