4

I create a dialog box with TimePicker inside it. This works very well on portrait mode, however, once it is changed into landscape mode, the TimePicker minus button looks cropped.

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"> 

    <TextView android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Time = " android:textSize="28dp"/>

    <TimePicker android:id="@+id/PickTime" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/text1" 
        android:layout_alignLeft="@id/text1"/>

    <Button android:id="@+id/StartStop" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Start"
        android:layout_below="@id/text1" 
        android:layout_toRightOf="@id/PickTime"/>

</RelativeLayout> 

My code for displaying the dialog box:

LayoutInflater factory;
factory = LayoutInflater.from(this);
View textEntryView = factory.inflate(R.layout.test, null);

AlertDialog dialog = new AlertDialog.Builder(this) 
    // .setTitle("Auto-Shutdown Setting")
    .setView(textEntryView)
    .setPositiveButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
            /* User clicked OK so do some stuff */
        }
    })
    .create();
dialog.show();

TimePicker timePicker = (TimePicker) dialog.findViewById(R.id.PickTime);
timePicker.setIs24HourView(true);
timePicker.setCurrentHour(12);
timePicker.setCurrentMinute(15);
timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
    public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
        // ...
    }        
});

Anyone knows why this is happening? Is it possible to customize the size of the dialog box (make it bigger)? Any other solution would be appreciated.


Edit by JJD:

Since I have a similar case with a combined date and time picker layout in a ScrollView I want to add screenshots here. @lwijono Please feel free to remove them if they do not show what you originally described. Or leave a comment and I will do so.

Pickers in portait mode

Pickers in landscape mode

JJD
  • 50,076
  • 60
  • 203
  • 339
lwijono
  • 389
  • 2
  • 5
  • 18
  • @lwijono: Why not just use `TimePickerDialog`? – CommonsWare Aug 26 '10 at 04:35
  • Well, I want to have another button on the side of the timepicker. I don't think we can add a button in a timepicker dialog. Can anyone verify that this is indeed a problem with the dialog? – lwijono Aug 28 '10 at 01:50
  • 1
    Can you show us a screenshot? – Andy Jan 12 '15 at 14:06
  • Please not this [`ScrollView` issue and solution](http://stackoverflow.com/questions/14354006/scrollview-fighting-with-scroll-of-timepicker-timepicker-not-scrolling-as-a-res) which I also noticed in my setup. – JJD Jan 12 '15 at 15:40

0 Answers0