androidtextstyle

how to get current text(font) style of edittext and set it to another edittext?


how to get current text(font) style of edittext and set it to another edittext?

code i tried

**lib i used:* easyfonts

t6.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //e1.setText("");

t6.setTypeface(EasyFonts.caviarDreams(getApplicationContext()));
                    text6=t6.getText().toString();
                    e1.setText(text6);
                }
            });

settext method setting normal text not styled


Solution

  • Use editText.getTypeface() to get the font of an edit text. Similarly, use editText.setTypeface() to set the font for another editText.

    Consider you have two edit text as e1 and e2, where you want to set font of e2 same as e1 just use e2.setTypeFace(e1.getTypeFace());.

    Go through the documentation for more details.