I am using the <TimePicker>
widget to enable the user to set the time.
However, since I'm embedding the <TimePicker>
into one of my views, I'd like to get rid of the TimePicker
's header (the crossed out area in the picture).
Default timepicker in Android looks like this:
Question: Is it possible to remove the timepicker's header and use only the analog part of the widget?
For example, android:layout_width="15dp" will set the width at a scalable value of 15. You can change 15 to whatever you want. If you want to set a specific pixel size, you can use, for example, 15px .
The android:scaleX="0.7" is what shrinked the visible picker (it works for DatePicker and TimePicker ) and the android:layout_marginLeft="-30dp" allowed for the space to be reduced.
There is no public method in TimePicker
to directly hide or show the Time Header. Try the below source code will give us the name of the resource ID for that View, which we can get with the system Resources. Then finding the View, and setting its visibility to GONE
.(I haven't tested)
private void hideTimeHeaderLayout(TimePicker picker) {
final int id = Resources.getSystem().getIdentifier("time_header", "id", "android");
final View timeLayout = picker.findViewById(id);
if(timeLayout != null) {
timeLayout .setVisibility(View.GONE);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With