I want to change the button font style when it clicks how can i achieve am new in android please help
Button b1=(Button)findviewbyid(R.id.login);
how can i select from pre_installed fonts . studio 3.0 has preinstalled fonts
I want to change the button font style when it clicks how can i achieve am new in android please help
Button b1=(Button)findviewbyid(R.id.login);
how can i select from pre_installed fonts . studio 3.0 has preinstalled fonts
You can use this:
Button b1 = (Button) findViewById( R.id.login );
b1.setOnClickListener( new OnClickListener() {
@Override
public void onClick(View v) {
Typeface newFont = getResources().getFont(R.font.myfont);
b1.setTypeface(newFont);
}
});
Get the font you need as a .ttf file and place it in your project's /assets/ directory. Use this code to refer to the font and set it to your button:
Typeface face= Typeface.createFromAsset(getAppContext().getAssets(), "LightBlueFont.ttf");
button.setTypeface(face);