I have a timepicker, everything works well but the problem is that I can\'t make it look like designer wants. For now it looks like this:
I need to hide this keybo
Okay this is my solution. After inspecting the Layout I found that the keyboard is AppCompatImageButton
. So you just do a recursion over the TimePicker
which is a Viewgroup
. So you can call it for example like this:
private fun initTimePicker() {
timePicker.setIs24HourView(true)
setImageButtonToGone(timePicker)
}
private fun setImageButtonToGone(viewGroup: ViewGroup) {
for (i in 0 until viewGroup.childCount) {
val child = viewGroup.getChildAt(i)
if (child is LinearLayout) {
setImageButtonToGone(child)
} else if (child is AppCompatImageButton) {
child.visibility = View.GONE
}
}
}
And you will get the desired layout.
WARNING!!! This depends heavely that the keyboard button is the only AppCompatImageButton
if they change the XML of TimePicker this will not work properly anymore.