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开发者_JAVA百科 what you originally described. Or leave a comment and I will do so.
精彩评论