Re: [android-developers] Getting android device Information
If you want to make sure your text size is always the same relative to the screen, you can do something along the lines of what Francisco suggests. Or, if you want to make sure your text is always say a quarter inch high, get ydpi from DisplayMetrics and compute the pixel size from that: on a 260 dpi device you'll need a 65 font, on 160 dpi just 40. On Thu, Jul 26, 2012 at 2:18 PM, Francisco M. Marzoa Alonso wrote: > AFAIK there is no way you could be sure that you are in front of a table > or a phone (or a TV). Bear in mind that in the future there may be even > other different device types. > > You better rely on screen density and/or resolution to calculate the > font size. That's what I do on my last casual game -still unpublished-. > > So, if you use a size of 10 for an screen that is 800 pixels height, you > may use a size of 20 for an screen that is 1600 pixels height. > > So you can do something like: > > realFontSize = (getWindowManager().getDefaultDisplay().getHeight() * 10) > / 800 > > Anyway I think it should be a more straightforward native way to do this > in most cases using dp or so, but I am not sure about. > > Hope a more advanced Android developer could give you a better answer, > but in the meantime you can use that code as a workaround. > > Regards, > > > > On 26/07/12 13:07, |-NK-| wrote: >> Hi >> >> I am developing an application that can be used on android phone and >> tablets. >> >> I have a UI on which I need to generate buttons on screen dynamically. >> >> I set font size of these buttons to 10 for phone devices, and it >> looked fine. >> But when I ran same for Tablet , the font was small and the buttons >> size too. >> >> I am using same class for handling UI on both tablet and phone, but >> using different layout xml files for tablet and phone. >> >> How can I find out which device am I using, so that I can set the >> button properties depending upon devices. >> >> I need to do something similar to this >> >> int size; >> if(device == Tablet) >> { >> size = 20; >> } >> else if(device == phone) >> { >>size = 10; >> } >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Getting android device Information
AFAIK there is no way you could be sure that you are in front of a table or a phone (or a TV). Bear in mind that in the future there may be even other different device types. You better rely on screen density and/or resolution to calculate the font size. That's what I do on my last casual game -still unpublished-. So, if you use a size of 10 for an screen that is 800 pixels height, you may use a size of 20 for an screen that is 1600 pixels height. So you can do something like: realFontSize = (getWindowManager().getDefaultDisplay().getHeight() * 10) / 800 Anyway I think it should be a more straightforward native way to do this in most cases using dp or so, but I am not sure about. Hope a more advanced Android developer could give you a better answer, but in the meantime you can use that code as a workaround. Regards, On 26/07/12 13:07, |-NK-| wrote: > Hi > > I am developing an application that can be used on android phone and > tablets. > > I have a UI on which I need to generate buttons on screen dynamically. > > I set font size of these buttons to 10 for phone devices, and it > looked fine. > But when I ran same for Tablet , the font was small and the buttons > size too. > > I am using same class for handling UI on both tablet and phone, but > using different layout xml files for tablet and phone. > > How can I find out which device am I using, so that I can set the > button properties depending upon devices. > > I need to do something similar to this > > int size; > if(device == Tablet) > { > size = 20; > } > else if(device == phone) > { >size = 10; > } > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Getting android device Information
Hi I am developing an application that can be used on android phone and tablets. I have a UI on which I need to generate buttons on screen dynamically. I set font size of these buttons to 10 for phone devices, and it looked fine. But when I ran same for Tablet , the font was small and the buttons size too. I am using same class for handling UI on both tablet and phone, but using different layout xml files for tablet and phone. How can I find out which device am I using, so that I can set the button properties depending upon devices. I need to do something similar to this int size; if(device == Tablet) { size = 20; } else if(device == phone) { size = 10; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en