How to make the TimePicker smaller

蹲街弑〆低调 提交于 2019-11-28 08:31:37

You cannot change the size of TimePicker, how ever you can do one thing. You can make TimePicker as a Dialog.

Checkout the following code:

Button setTime;
setTime = (Button)findViewById(R.id.button1);
setTime.setOnClickListener(this);

public void onClick(View v) 
{
    TimePickerDialog tp1 = new TimePickerDialog(this, this, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);
    tp1.show();
}

public void onTimeSet(TimePicker view, int hourOfDay, int minute)
{
    cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
    cal.set(Calendar.MINUTE, minute);
    //rest of the code
}

You can do this. I had also same problem. But Google helped me. You have to just change your XML file.

android:scaleY="0.90" & android:scaleX="0.90"

It will small your picker with percentage value which you provide.

Works only from API 11.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!