I am trying to get the time picker to display the full clock in landscape. The TimePicker
is in a GridLayout
. It does not overlay the screen as a DialogFragment
or a TimePickerDialog
.
Currently, this is what it shows in landscape:
As you can see, there is nothing you can pick the time with, only the default time. I am trying to get it to show the clock as well just like in portrait (which works):
The layout of the time picker:
<package.name.ScrollableTimePicker
android:id="@+id/time_picker"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
The class that extends TimePicker
:
public class ScrollableTimePicker extends TimePicker {
public ScrollableTimePicker(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ScrollableTimePicker(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollableTimePicker(Context context) {
super(context);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// Keeps events to time picker
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
ViewParent p = getParent();
if (p != null) {
p.requestDisallowInterceptTouchEvent(true);
}
}
return false;
}
}
I looked around the internet and found these posts that did not help me:
I do not have a title for my time picker.
It has already been implemented
Tried the code in manifest but still did not work.
UPDATE
As siddesh has suggested, setting layout_height
of the TimePicker
to 200dp
works but it cuts off the portrait. Now, the portrait is 200dp
tall but is cut off and the landscape is shown fully: