Create elegant buttons

How to create or load elegant / stylish buttons (Widgets) instead of simple buttons?

+4
source share
1 answer

If you want to create a legitimate, fully implemented skin for a button, you can make a 9 patch using a list of states.

9-patch-drawable - standard version with sections that can be repeated; e.g. upper left, upper, upper right, middle left, etc. parts of the button.

(Here you can read the detailed information: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch )

The displayed list of states is available for drawing, which changes its resource in accordance with a certain state. In the case of a button, normal, highlighted and pressed are states.

http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

Thus, you really need to make three templates with nine patches and a list of states suitable for connecting these three nine patches.

A few other ways to do this:

  • Subclass a View and create your own button from scratch.
  • Someone else mentioned ImageButton
+8
source

Source: https://habr.com/ru/post/1336736/


All Articles