Defining custom attrs

I need to implement my own attributes like in com.android.R.attr Found nothing in official documentation so I need information about how to define these attrs and how to use them from my code.