How to use custom buttons?

Asked

Viewed 1,012 times

-1

I would like to know how to put buttons more "attractive" (edit your aesthetic) in the app and also how to add fonts?

  • is quite ample, but from what I understand you want to know how to modify the appearance of a button and change the source of textViews/checkboxes... correct?

1 answer

1

To modify the source of a Textview for example: you must first add it to your project in android studio, as follows...

1º => Create the Assets folder in app/src/main/Assets... If you have difficulty locating, change the view of your project:

inserir a descrição da imagem aqui

2º => copy the source (.otf or .ttf) you want to that Assets folder you created.

3º => in your Activity code state the source as follows (in the example I used the source orange_juice):

Typeface font = Typeface.createFromAsset(getAssets(), "orange_juice.ttf");

(if your source is . otf, then put . otf)

For the source to be effected in a Checkbox or Textview just do the following:

Typeface font = Typeface.createFromAsset(getAssets(), "orange_juice.ttf");

CheckBox checkBox = (CheckBox)findViewById(R.id.checkBox);
TextView textView = (TextView)findViewById(R.id.textView);

checkBox.setTypeface(font);
textView.setTypeface(font);

(remember to first add them to the layout)

To change the appearance of a button (if that’s what I understand), just do the following:

1º => add the image you want to the Drawables folder.

2º => in the button properties, select the background tab:

inserir a descrição da imagem aqui

3º => select the desired image (in my case Lamp):

inserir a descrição da imagem aqui

Ready! If you have anything else, comment.

  • Oh yes I understand, is there a site that I find these fonts available for download? Thank you from now buddy

  • https://fontzone.net/ if nn me mistakenly tbm was lah where I downloaded the source of the example of the SP

  • REMEMBERING THAT NOT ALL ARE FREE FOR COMMERCIAL USE if you want to use them in your app you may have to buy them

  • It’s good , man thanks even saw helped me a lot

  • It did not work , the error application when opening , my code is like this

  • so how? put an Edit in your question

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.