In my application I am using Date picker dialog.During testing some emulator show date picker dialog properly but some emulator show the data picker dialog in properly.Can you explain whether this is a emulator problem or functionality problem as well as how to solve this problem.Thanks...
new DatePickerDialog(getSherlockActivity(), datePicker,
calendarTaskDate.get(Calendar.YEAR),
calendarTaskDate.get(Calendar.MONTH),
calendarTaskDate.get(Calendar.DAY_OF_MONTH)).show();
Here i enclosed the screen shot for both.
Emulator Name:
5.1" WVGA(480x800:mdpi),API level:17
Emulator Name:Nexus S(4.0",480x800:hdpi) API 12
Android's default DatePickerDialog's layout will be changed according to the API's based on its themes. For the different API's there is a different layout so if you have API below 8 it will be same as your first screenshot. As you go for higher API above 13 you will always get the different layout for your DatePickerDialog.
So Its not on our hand to maintain the same layout for DatePicker.
To me both images look ok.
If what you think is the problem is that the display is not the same it is simply due to the fact that in one emulator you use API 17 and in the other one API 12.
In those two API the look of the date picker is not the same.
Related
I am using date and time picker in my application and referred the tutorial
from here but the problem is that when i run it on kitkat 4.2.2 it show output as follows: but when i run it on lollipop 5.1.1 it shows output
showing two different UI on same code i dont know how to fix this problem.I have also applied some validations on it but its working with first case but not with second case.Please help.
if you want it identical to the first one you can add
android:datePickerMode="spinner"
android:calendarViewShown="false"
This differs as per OS version in devices. It is a system date and time picker.
So it will be as per OS version and may - may not differ in each of the OS version.
Whatever you are seeing is correct and is OS level change.
I think you can force it to look a certain way by changing compilessdkversion and the targetsdkversion accordingly in your gradle file.
edit: on second thought, I'm not 100% sure it'll work...might cause problems on some versions.
The 100% positive way to get the classic spinner is like Maxi said to set the attribute datepickermode atribute to spinner.
To answer whats been asked of Maxi regarding timePicker. You have to set the timePickerMode attribute to "spinner" in a similar fashion to avoid the round clock interface and get the classic spinner.
<TimePicker
...
android:timePickerMode="spinner" />
I'm developping an Android app and right now I'm having an issue with a part of my UI: a TimePickerDialog. I'd like the top part of the Dialog to be orange instead of the classic
I know that I could create a custome theme, but my boss want it developp in 4.0 (API 15) so that it covers almost every device.. I don't know how to set a color with using settings covered by API 21 and up..
TimePickerDialog appearance is very different in the API levels you are testing on. The biggest redesign was probably made in Lollipop (API 21), where the default dialog has a totally different (circular) look:
If you are testing on API21+, you are probably seeing this one. The background color AFAIK can be changed by tweaking the android:color* attributes in your theme. I'm not sure which one (could be android:colorAccent, android:colorPrimary...), but it is easy to determine.
However, since you are going to deploy down to API 15, and default time picker there is quite different, I would recommend using an external library to give each user the same look and feel of Lollipop.
The most used is probably this one, and allows you to style the dialog in terms of colors and much more.
API>=21:You can define <item name="colorPrimary">xxxx</item> in your style of theme
API<21:Use libary for example material libary
I am using a calendar view inside a dialog fragment .I am getting the one as shown below. I am using the default calendarview provided.
But instead i want to get a calendar view as this one , which is shown by default in xml when i add:
I have tried changing the style to Widget.DeviceDefault.Light.CalendarView , Widget.Material.CalendarView but with same effect.
If you're using prolificinteractive materialcalendarview library, to change header style for year and month.
check my answer here:
How can I change Android MaterialCalendarView month color?
I don't know How to create Custom Calendar but you might check this GitHub library.You may succeed in creating the one, you are asking for with just little customization
https://github.com/prolificinteractive/material-calendarview
And also Refer to this Useful Stackoverflow post from which you will definitely be able to implement a CalenderView as you wanted.
Custom Android calendarView
At first I didn't understand why CalendarView component looks different in Android Studio and on my phone, but then I found this post https://stackoverflow.com/a/45368436/11052714
So the reason you are seeing this on your phone is because of API level. In the post I mentioned above, however I think wrong API level is mentioned, because I have the old calendar view with Android version 5.0.2 aka API level 21. It means that still in API level 21 old Calendar View visual look is used.
I tryed to use DatePicker dialog on Kindle. But Edit fields without the background! How I can to fix it (standard-way)? You can check it in emulator. I use Android 2.2 for building application.
I was having the same problem. I was able to solve it by calling the DatePickerDialog's setInverseBackgroundForced and passing in true.
I've got an preference screen with android:dialogLayout="#layout/my_own_layout"
I would like to make my own dialogLayout look almost exactly like the default one, only with some minor changes (adjusting the spaces between title and summary).
Is there any way I can get the default layout? With the text sizes, paddings and so on?
Any help is appreciated.
You can always check the default layouts in different platforms and you can modify them.
For instance you can access the alert dialog layout in the following path:
android-sdk\platforms\android-15\data\res\layout\
for Android API LvL 15.
You can search for other api levels anytime to check different layouts there.