package Ġai . ron nick n ach ok . custom keyboard Ċ Ċ import Ġai . ron nick n ach ok . custom keyboard . components . keyboard . Custom Keyboard View Ċ import Ġai . ron nick n ach ok . custom keyboard . components . text Fields . Custom TextField Ċ import Ġai . ron nick n ach ok . custom keyboard . components . utilities . Component Utils Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Button Ċ import Ġandroid . widget . LinearLayout Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ Ċ class ĠAdvanced Features Activity Ġ: ĠAppCompatActivity () Ġ{ Ċ ĉ private Ġlateinit Ġvar Ġkeyboard : ĠCustom Keyboard View ĊĉĊ ĉ override Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . onCreate ( savedInstanceState ) Ċĉ ĉ set ContentView ( R . layout . activity _ advanced _ features ) ĊĉĉĊĉ ĉ val Ġcustom Field Wrapper : ĠLinearLayout Ġ= ĠfindViewById ( R . id . custom Field Wrapper ) Ċĉ ĉ custom Field Wrapper . addView ( Ċĉĉ ĉ create Custom TextField ( Ċĉĉĉ ĉ " Custom ĠNumber ĠKeyboard ", Ċĉĉĉ ĉ Custom Keyboard View . Keyboard Type . NUMBER Ċĉĉ ĉ ) Ċĉ ĉ ) Ċĉ ĉ custom Field Wrapper . addView ( Ċĉĉ ĉ create Custom TextField ( Ċĉĉĉ ĉ " Custom ĠNumber ĠDecimal ĠKeyboard ", Ċĉĉĉ ĉ Custom Keyboard View . Keyboard Type . NUMBER _ DECIMAL Ċĉĉ ĉ ) Ċĉ ĉ ) Ċĉ ĉ custom Field Wrapper . addView ( Ċĉĉ ĉ create Custom TextField ( Ċĉĉĉ ĉ " Custom ĠQ WER TY ĠKeyboard ", Ċĉĉĉ ĉ Custom Keyboard View . Keyboard Type . Q WER TY Ċĉĉ ĉ ) Ċĉ ĉ ) ĊĉĉĊĉ ĉ keyboard Ġ= ĠfindViewById ( R . id . custom Keyboard View ) Ċĉ ĉ keyboard . auto Register EditText s ( custom Field Wrapper ) ĊĉĉĊĉ ĉ val Ġswitch Activities Button : ĠButton Ġ= ĠfindViewById ( R . id . switch Activities Button ) Ċĉ ĉ switch Activities Button . setOnClickListener Ġ{ Ċĉĉ ĉ startActivity ( Ċĉĉĉ ĉ Intent ( Ċĉĉĉĉ ĉ this @ Advanced Features Activity , Ċĉĉĉĉ ĉ MainActivity :: class . java Ċĉĉĉ ĉ ) Ċĉĉ ĉ ) Ċĉ ĉ } Ċ ĉ } ĊĉĊ ĉ private Ġfun Ġcreate Custom TextField ( Ċĉ ĉ hint : ĠString , Ġkeyboard Type : ĠCustom Keyboard View . Keyboard Type Ċ ĉ ): ĠCustom TextField Ġ{ Ċĉ ĉ val Ġfield Ġ= ĠCustom TextField ( application Context ) Ċĉ ĉ val Ġlp Ġ= ĠLinearLayout . LayoutParams ( Ċĉĉ ĉ Component Utils . dp To Px ( application Context , Ġ 4 0 0 ), Ċĉĉ ĉ ViewGroup . LayoutParams . WRAP _ CONTENT Ċĉ ĉ ) Ċĉ ĉ val ĠmarginBottom Ġ= Ċĉĉ ĉ application Context . resources . get Dimension ( R . dim en . field Margin Bottom ). toInt () Ċĉ ĉ lp . set Margins ( 0 , Ġ 0 , Ġ 0 , ĠmarginBottom ) Ċĉ ĉ field . layout Params Ġ= Ġlp ĊĉĉĊĉ ĉ field . hint Ġ= Ġhint Ċĉ ĉ field . keyboard Type Ġ= Ġkeyboard Type ĊĉĉĊĉ ĉ return Ġfield Ċ ĉ } ĊĉĊ ĉ override Ġfun Ġon Back Pressed () Ġ{ Ċĉ ĉ if Ġ( keyboard . is Expanded ) Ġ{ Ċĉĉ ĉ keyboard . translate Layout () Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ super . on Back Pressed () Ċĉ ĉ } Ċ ĉ } Ċ }