That depends on your purpose. If you want to create keyboard specifically to any activity then follow below tutorial.
http://tutorials-android.blogspot.in/2011/06/create-your-own-custom-keyboard-for.html
Or if you want to create keyboard that will replace default keyboard in all applications then following answer will be helpful to you.
https://stackoverflow.com/questions/14806087/android-facebook-emoji-keyboard/14826813
As you said you want to change layout of keyboard then read this.